0 US Holidays Web Request Shared by Mike Mundy, Bedford Alliance Church 19 days ago 15.0 Event, General, Web Intermediate I recently rebuilt our staff internal calendar to bring everything into one place—room reservations, events, PTO requests, staff birthdays, and even U.S. holidays. While most of those items naturally lived inside Rock, the holidays were a unique challenge. I didn’t want to waste time manually entering them each year—or risk forgetting updates. Instead, I needed a reliable, automated way to pull them in.In this recipe, I’ll walk you through how I connected our calendar to the Google Calendar API via a Web Request, allowing U.S. holidays to display automatically—no manual upkeep required. ** Note: To do this, I manually built a calendar into our UI. I did not use the native Calendars features within Rock.Google Calendar APILet's start by enabling the Google Calendar API.Login to Google Cloud https://console.cloud.google.comWhen you first started with Rock, you most likely enabled the Google Maps API for use within Rock. I used our same account to login to Google Cloud. I recommend this approach.Via the main left-hand menu, navigate to APIs and Services.At the top of the page, search for Google Calendar API. Enable it.Back on the APIs and Services page, select "Credentials".Create a new API key. You may be able to reuse your existing Maps API key, but I created a new one so I could set separate and be more restrictive with the APIs permissions. I recommend this approach.For your new API key, you want your restrictions to be "IP Addresses". Then add the IP Address of your Rock Server. (You can add multiple if you have a dev server.) Then, select "Restrict Key" and select the Google Calendar API from the dropdown.SaveTake note of your API Key... you will need it later.Here is a quick screenshot of how it should look:Web RequestNow we setup the Web Request in Rock. Choose where you want to set this up. I started in Lava Tester to see how it worked, then moved on from there once I had it working. Wherever you choose, make sure the Web Request Lava Command is enabled. Start by creating some Date variables. Feel free to adjust this to meet your needs. We have our DateAdds set to 28 and 21 instead of 84 and 77.. I increased it for this recipe so you would be able to return more results.{% assign day = 'Now' | Date:'ddd' %}{% if day == 'Sun' %} {% assign startDate = 'Now' | Date %} {% assign endDate = 'Now' | SundayDate | DateAdd:84,'d' | DateAdd:-1,'s' %}{% else %} {% assign startDate = 'Now' | SundayDate | DateAdd:-7,'d' %} {% assign endDate = 'Now' | SundayDate | DateAdd:77,'d' | DateAdd:-1,'s' %}{% endif %}Now, let's capture the Web Request URL. You will notice a few parameters are passed in. You do not have to include a timeMin or timeMax, but if you don't it will return A LOT of holidays. We only need the ones we plan to display. You'll also notice at the end is "&key=". This is where you place your API key from your new Google Calendar API.{% capture googleCalendarUrl %}https://www.googleapis.com/calendar/v3/calendars/en.usa%23holiday%40group.v.calendar.google.com/events?timeMin={{ startDate | Date:'yyyy-MM-dd' }}T00%3A00%3A00Z&timeMax={{ endDate | Date:'yyyy-MM-dd' }}T23%3A59%3A59Z&key=enteryourapikeyhere{% endcapture %}Here is the Web Request.{% webrequest url:'{{ googleCalendarUrl }}' %} {% assign holidays = results.items %}{% endwebrequest %}And finally, let's display it! You can decide how you want your results to display, but this is just a simple way to do it with JSON.{% for holiday in holidays %} { "Summary": {{ holiday.summary | ToJSON }}, "Date": {{ holiday.start.date | ToJSON }} }{% unless forloop.last %},{% endunless %}{% endfor %}Thats it! You should have a list of all the upcoming US Holidays. You can find all the information available to you by doing {{ Lava | Debug }} on the page. More FunAs I mentioned at the beginning, I combined multiple data sources into one unified calendar, so everything is in one place. I added the US Holiday feed into a Persisted Dataset, amongst other things, and then display all of it neatly on our internal homepage. That way, staff can quickly see what’s coming up—whether it’s a Room Reservation, Event, a PTO request, or an upcoming U.S. holiday.Here is a quick screenshot of how I display our calendar. There is always A LOT more information displayed, but for this recipe it's only showing the US Holiday.