juftin / camply

camply, the campsite finder ⛺️ - a tool to find campsites at sold out campgrounds through sites like recreation.gov
https://juftin.com/camply/
MIT License
464 stars 89 forks source link

`POLLING_INTERVAL_MINIMUM` limit clarification #294

Closed rtmlp closed 11 months ago

rtmlp commented 11 months ago

Hi,

Why is the POLLING_INTERVAL_MINIMUM set to 5 minutes. Is it minimum interval suggested by the API provider ?

Thanks

juftin commented 11 months ago

The minimum polling interval is set to 5 minutes so we don't overload the APIs of our friends the booking providers. but I've found the 5 minute limit to be reasonable and haven't heard any complaints yet from providers or users.

camply kind of skirts the edge on whether or not it is a tool that our providers approve of. There aren't any suggested limits or guidance from the API providers - so I like to err on the side of caution.

Do you have a use case where you need to check more often than every 5 minutes?

rtmlp commented 11 months ago

Thanks a lot for the explanation.

My motivation for the question: I am using the personal API key and noticed that I received a notification for a campground through campflare which I missed through camply. So I got curious if the POLLING_INTERVAL_MINIMUM might have some influence on it and hence I asked the question

Does it make sense to edit/add the POLLING_INTERVAL_MINIMUM as environment variable ?

juftin commented 11 months ago

There isn't a polling interval minimum enforced on the RIDB API - this API is used to provide metadata about the campsites / recreation areas and it requires API creds. Instead the polling interval is set on the "availability" API. For RecDotGov, the availability API is at https://www.recreation.gov/api/camps/availability and doesn't use API credentials - instead we spoof a web browser. This is an unofficial web-facing API and Recreation.gov doesn't give us any guidance on how often we can ping it.

Camply will fan out across all of your selected campgrounds and search dates and make multiple requests to the availability API. After checking it then "sleeps" for the set POLLING_INTERVAL before trying again.

If campflare checks more often than 5 minutes it's possible a site became available and was booked in between camply's searches. Of course this is possible the other way around too where camply happens to search at the right interval to find something between campflare searches.

If you need to check more often than 5 minutes I would recommend running camply as a cron job.

rtmlp commented 11 months ago

Thanks a lot for providing detailed explanation about API and the polling interval. For my use, your suggestion of running it as a cron job makes more sense. Thanks for pointing me towards this link