Preventing Google Photos API limit from being exceeded
Closed this issue · 2 comments
According to Google Photos API specification:
All requests sent to the Google Photos Library API are counted toward a quota. We put these limits in place to protect the system and its users.
...
The quota limit for requests to the Library API is 10,000 requests per project per day.
and
this issue(#89) I need to find a way how to minimize number of requests (currently the whole data is taken every frame refresh, 50 items every time /another Google limit/).
The solution is to store downloaded Google Photos API data once a day and then load it when needed. As we have Pandas on board I can use a simple DataFrame dump/load mechanism (Feather format seems to be fast and enough for this). The data will be downloaded at first run every day and then for the rest it will be loaded and reused. The problem is that photos download URLs are expiring but in that case I can refresh it when something like this happens (with two retries). With that refresh requests number will be maximum 2% of the 10k requests limit, leaving the rest for the initial download.
This setting controls this behavior:
https://github.com/MikeGawi/ePiframe/blob/master/config.cfg#L30
always = every frame refresh, once = once a day