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

Rate Limits #7

Open
thedavecarroll opened this issue Mar 10, 2019 · 1 comment
Open

Rate Limits #7

thedavecarroll opened this issue Mar 10, 2019 · 1 comment

Comments

@thedavecarroll
Copy link

Each Twitter API endpoint has a specific rate limit for the standard API.

You can find more information on Twitter's standard API rate limiting here.

For instance, here are the rate limits for lists endpoints.

/lists/list             : @{limit=15; remaining=0; reset=1552260236}
/lists/memberships      : @{limit=75; remaining=75; reset=1552260742}
/lists/subscribers/show : @{limit=15; remaining=15; reset=1552260742}
/lists/members          : @{limit=900; remaining=900; reset=1552260742}
/lists/subscriptions    : @{limit=15; remaining=15; reset=1552260742}
/lists/show             : @{limit=75; remaining=75; reset=1552260742}
/lists/ownerships       : @{limit=15; remaining=15; reset=1552260742}
/lists/subscribers      : @{limit=180; remaining=180; reset=1552260742}
/lists/members/show     : @{limit=15; remaining=15; reset=1552260742}
/lists/statuses         : @{limit=900; remaining=900; reset=1552260742}

After reaching the limit, the current Invoke-TwitterAPI calling function generates an error similar to the following:

Invoke-RestMethod : {"errors":[{"message":"Rate limit exceeded","code":88}]}
At C:\Program Files\PowerShell\Modules\PSTwitterAPI\0.0.7\public\Invoke-TwitterAPI.ps1:34 char:5
+     Invoke-RestMethod @RestMethod_Params
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (Method: GET, Re...rShell/6.1.2
}:HttpRequestMessage) [Invoke-RestMethod], HttpResponseException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

How should rate limits be handled?

@mkellerman
Copy link

Inside each Public function for each endpoint, you'll notice that there is this line:
If (-Not $OAuthSettings) { $OAuthSettings = Get-TwitterOAuthSettings -Resource $Resource }

Get-TwitterOAuthSettings searches all the configured OAuthSettings for a resource that is available. And will rotate between all the APIKeys, allowing you to surpass the limits on once single Twitter API Application, by adding multiple APIKeys.

If none are found, it's going to generate this Rate limit exceeded, but in reality, we should simply 'Wait' for one to be available again.

View the current issue here:
mkellerman#12

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

No branches or pull requests

2 participants