API:Best practices

From Guild Wars 2 Wiki
Jump to navigationJump to search

This pages serves as a list of best practices when it comes to working with the API, as it has many inconsistencies that accumulated over the years or simply general guidelines of how to work with it.

Common problems

Rate Limit

Max Burst Size (bucket size): 300

Refill Rate: 5 tokens per second (300 per minute)

With 300 burst and a refill of 5 tokens per second, you will get a reliable stream of requests with no 429s.

Invalid API-Keys

Sometimes API-Keys that are otherwise perfectly fine will return "Invalid key" randomly, when retrying the same key it often times works perfectly fine afterwards. It is recommended to keep retrying the key at a later time or in intervals instead of just marking it as invalid.

Schema Changes

When using an ISO Datetime to force a particular schema version, it is important to bear in mind that changing enum values is not considered a breaking change. Depending on your chosen language and modelling this could lead to errors if your application cannot handle unexpected values in enums. Thus it is important to make sure you handle unexpected values for enums. For instance, in API:2/continents the region field inside the mastery_points entries was updated to add the value Jade as an enum option without an API schema change.

External resources