Canada Holidays

KOSTENLOS
Durch Paul Craig | Aktualisiert a month ago | Events
Popularität

7.9 / 10

Latenz

223ms

Service Level

100%

Health Check

N/A

Zurück zu allen Diskussionen

Multiple years?

Rapid account: Jjtagh
jjtagh
3 years ago

Thanks for this resource! I’m new to APIs - how would I setup the header to include this year and next year?

FYI I’m using Power Query so my current string looks like this:

= Json.Document(Web.Contents(“https://canada-holidays.p.rapidapi.com/api/v1/holidays?year=2021&federal=1”, [Headers=[#“x-rapidapi-key”=“040aa8b22fmshf3d978f9313666bp146783jsnf7e45e885309”]]))

Once I understand how to construct the request for multiple years, I’d like to replace the hard-coded value with parameter(s).

Thanks!

Rapid account: Pcraig 3
pcraig3 Commented 2 years ago

Hello!

By the “bare-metal interface”, I just mean that RapidAPI provides their own endpoints but there is probably some extra latency because they are just calling my URL behind the scenes.

If you wanted to just use “https://canada-holidays.ca/api/v1”, that might save you a hundred milliseconds or so. No need to switch if it’s working for you, but it might be slightly faster not to use it.

Paul

Rapid account: Jjtagh
jjtagh Commented 3 years ago

Hi Paul, thanks for the reply! Absolutely I can, and that is exactly what I did- 2 quick calls and an append table, and I have a nice dynamically generated table with at minimum 1 year (+ 1 day’s) holidays. My question comes mostly from this being my very first API call, and not yet having a second clue about their inner workings.

Re: “are you sure you need it?”

My application is asking “when should I schedule manufacturing work hours over the next day(s), month(s)?” So, if it’s say, December 17, I need to know if any upcoming holidays will impact product delivery expectations. If I have only till the end of the current year, I will end up allocating work to New Year’s Day and Family Day here in BC. Could I update a static table once a year? Sure but what fun would that be? And it was time for me to start playing with API’s.

And Re: “You can also use the bare-metal interface, it might save a bit of latency.” … googling “bare-metal interface”…

Cheers, and thanks again for maintaining this for some reason 😃
Jeff

Rapid account: Pcraig 3
pcraig3 Commented 3 years ago

Hi there,

Thanks for the question! Someone asked this on Github, and I will paste the answer below.

“One of my core architectural assumptions is that I calculating all the holidays for one year at a time. It wouldn’t be impossible to make the change you’re suggesting, but the API and frontend that are both running off the same backend logic in getHolidays, which which always returns all the holidays for 1 year. Almost all my routes are using this one function (defaulting to the current year if there is no explicit parameter).”

“That’s not a ‘no’, instead it’s an “are you sure you need it?”. For me, I can see the value but it’s a reasonably hard change to make at this point. My previous stance on this has been “just make a few calls in a row on your end” and I can keep the interface simple.”

TL;DR, it would be a pretty big refactor for me to allow multiple years at once. Can you manage it on your end, and make multiple calls? (You can also use the bare-metal interface, it might save a bit of latency.)

Cheers,

Paul

Nehmen Sie an der Diskussion teil - fügen Sie unten einen Kommentar hinzu:

Anmelden / Registrieren, um neue Kommentare zu veröffentlichen