Optimizing API Calls #13032
Replies: 1 comment 2 replies
-
https://docs.weblate.org/en/latest/api.html#get--api-components-(string-project)-(string-component)-statistics- gives you statistics for all the translations instead of fetching them individually The lock state could be included in the component info, I've created #13035 to implement that. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have build myself a dashboard where I monitor translation progress of my watched projects and get information when strings need to be taken care of. When I need a look at that info I just open the dashboard it makes the API calls needed, and after few seconds I get that presented in a nice purple pseudo-table. Unfortunately now due to the large(?) amount of watched projects (being around 80 components in 20 projects) I hit some API rate limit. Most probably those are 1 minute limits because I'm always within the hour limit. After ~130 requests I get
HTTP/1.1 503 Service Temporarily Unavailable
. I keep a list of the projects and components of interest over which I iterate and make the following calls:https://hosted.weblate.org/api/components/{$projectSlug}/{$componentSlug}/
- from it I usecomponent.project.name
andcomponent.name
https://hosted.weblate.org/api/translations/{$projectSlug}/{$componentSlug}/{$language}/statistics/
- from it I get most of the interesting data the number of strings, translated percentage etc.https://hosted.weblate.org/api/components/{$projectSlug}/{$componentSlug}/lock/
- from it I get the locked state of the project.I space out each request by 50 ms and additional 50 ms per project.
My request is if anyone with more experience with the API sees a way to optimize the number of queries without losing current set of data to share it with me.
The obvious solution is ether ditch the
lock
query altogether (and temporary make room for a few more components before hitting the same rate limit) or rise the waiting time between queries hoping to pass over the 1 minute mark.Beta Was this translation helpful? Give feedback.
All reactions