nkl-kst / the-sports-db

PHP library to get sports data from TheSportsDB (https://www.thesportsdb.com)
MIT License
22 stars 3 forks source link

Throttle requests (rate limit) #53

Closed nkl-kst closed 1 year ago

nkl-kst commented 1 year ago

As described in https://www.thesportsdb.com/forum_topic.php?t=5749, requests should be limited "to at maximum 2 per second". The API returns a 429 Too Many Requests when exceeding this limit:

Client error: `GET https://www.thesportsdb.com/api/v1/json/HIDDEN_KEY/lookup_all_teams.php?id=4570&` resulted in a `429 Too Many Requests` response:
{                                                                    
    "message": "Rate Limit exceeded. Please keep below 100 requests per 1 minute. ",                                                         
    "error": 429                                                         
}   

This should be an optional feature/configuration for users who know there will be a lot of requests in their script.