Error handling

Your account and developer keys are rate limited.

To prevent abuse of server side resources, we have to impose rate limits.

Thus, it is possible that your request may not succeed if you exceed your rate limit.

In the rare case that the service is scaling out, it is also possible you might encounter timeouts.

Therefore, it is always advisable to handle errors with appropriate logic to retry requests.

from import APIError, APIDataValidationError
import time

num_retries = 3
for i in range(num_retries):
        # Your code
    except APIError as ex:
        # Check if rate limit was exceeded
        if ex.retry_after:
            # Rate limit was exceeded, you could sleep
            # for the suggested time and retry the request
    except APIDataValidationError:
        # You are sending us incorrect data
        # log your data, and fix your code
    except Exception:
        # Some other problem occurred,
        # log the error, and retry