ChimeraCoder / anaconda

A Go client library for the Twitter 1.1 API
MIT License
1.14k stars 247 forks source link

EnableThrottling for GetFollowersIdsAll #253

Open xfreakart opened 6 years ago

xfreakart commented 6 years ago

Hi,

I'm trying to get all Followers Id's of a "big" account. Twitter limits 5K results per page (pagination) every 15 min. So I tried to set EnableThrottling with:

    api := anaconda.NewTwitterApiWithCredentials(AT, ATS, CK, CS)
    api.EnableThrottling(duration, 1)

When I call GetFollowersIdsAll I though that internally even that is just one query that I'm making it would apply EnableThrottling.

result := api.GetFollowersIdsAll(v)
    for id := range result {
        fmt.Println(id)
    }

It does not. It follows the pagination so when It has to load the second part It gets the error "Rate limit exceded".

returned status 429, {"errors":[{"message":"Rate limit exceeded","code":88}]}}

Was this a misunderstanding of EnableThrottling usage or there is another aproach for this?

Thanks!

rumd3x commented 4 years ago

As I understand, anaconda has built-in rate limit handling, when you call EnableThrottling you turn that off, as you choose to throttle the requests manually yourself.

From the README:

If you make queries too quickly, you may bump against Twitter's rate limits. If this happens, anaconda automatically retries the query when the rate limit resets, using the X-Rate-Limit-Reset header that Twitter provides to determine how long to wait.

In other words, users of the anaconda library should not need to handle rate limiting errors themselves; this is handled seamlessly behind-the-scenes. If an error is returned by a function, another form of error must have occurred (which can be checked by using the fields provided by the ApiError struct).