Skip to content

Adds code to deal with rate limits imposed by Product Hunt API#4

Open
luizvbo wants to merge 1 commit intoanatg:masterfrom
luizvbo:rate_limit_code
Open

Adds code to deal with rate limits imposed by Product Hunt API#4
luizvbo wants to merge 1 commit intoanatg:masterfrom
luizvbo:rate_limit_code

Conversation

@luizvbo
Copy link

@luizvbo luizvbo commented Sep 14, 2018

Each API response includes 3 rate limit headers. You can use these
headers to check your current rate limit status.

  • X-Rate-Limit-Limit: Your applications limit for the 15 minute period
  • X-Rate-Limit-Remaining: Remaining allowed requests for the reset
    period
  • X-Rate-Limit-Reset: Seconds until the rate limit is reset

The methods _update_time_limits is called at each request and updates
three new atributes of the class responsible for keeping track of these
three limits. The method get_rate_limits is used to acess these values
and wait_if_no_rate_limit_remaining wait the limit to be restabilished
before making a new request.

Each API response includes 3 rate limit headers. You can use these
headers to check your current rate limit status.

- X-Rate-Limit-Limit: Your applications limit for the 15 minute period
- X-Rate-Limit-Remaining: Remaining allowed requests for the reset
period
- X-Rate-Limit-Reset: Seconds until the rate limit is reset

The methods `_update_time_limits` is called at each request and updates
three new atributes of the class responsible for keeping track of these
three limits. The method `get_rate_limits` is used to acess these values
and `wait_if_no_rate_limit_remaining` wait the limit to be restabilished
before making a new request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant