Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does twitter-lite report the current status of rate limits, in order to get the count of the API requests remaining in the current time-window? #199

Open
0xtetus opened this issue Jul 17, 2022 · 1 comment

Comments

@0xtetus
Copy link

0xtetus commented Jul 17, 2022

I'm using twitter-lite to periodically check the "followers" of 4 Twitter accounts. I know there's a rate limit for this operation, and since I'm creating a bot that people can trigger I want to make sure I don't hit the rate limit.

So just looking for a way to find out the number of requests I have left in each time-window. Is there a way to calculate this with twitter-lite or does Twitter API even report this number?

I'm open to any other ways or suggestions to tackle this.

@steven-t-h
Copy link

steven-t-h commented Nov 12, 2022

@0xtetus don't know if you ever found out, but it looks like the post method returns _header that will contain the response headers:

/**
   * Send a POST request
   * @param {string} resource - endpoint, e.g. `users/lookup`
   * @param {object} body - POST parameters object.
   *   Will be encoded appropriately (JSON or urlencoded) based on the resource
   * @returns {Promise<object>} Promise resolving to the response from the Twitter API.
   *   The `_header` property will be set to the Response headers (useful for checking rate limits)
   */
  post(resource, body)
...

There's an x-rate-limit-remaining header returned that should have what you're looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants