Requesting User Tweets using Application-only Authentication


#1

I’m attempting to request the tweets of mulitple users usign app-only authentication. No problems getting the bearer token or requesting tweets for the first 8 users.

Example for the 8th user:
HTTP Response for CoachJBGrimes:{
“Cache-Control” = “no-cache, no-store, must-revalidate, pre-check=0, post-check=0”;
“Content-Encoding” = gzip;
“Content-Length” = 907;
“Content-Type” = “application/json;charset=utf-8”;
Date = “Thu, 08 Aug 2013 17:09:41 GMT”;
Expires = “Tue, 31 Mar 1981 05:00:00 GMT”;
“Last-Modified” = “Thu, 08 Aug 2013 17:09:41 GMT”;
Pragma = “no-cache”;
Server = tfe;
Status = “200 OK”;
“Strict-Transport-Security” = “max-age=631138519”;
“x-access-level” = read;
“x-frame-options” = SAMEORIGIN;
“x-rate-limit-limit” = 15;
“x-rate-limit-remaining” = 0;
“x-rate-limit-reset” = 1375982680;
“x-transaction” = deffd8ccf1d6bfee;
}

However, when I request the next user I get:

HTTP Response for CoachTonyBarbee:{
Connection = close;
“Content-Encoding” = gzip;
“Content-Type” = “application/json; charset=utf-8”;
Date = “Thu, 08 Aug 2013 17:09:42 UTC”;
Server = tfe;
“Strict-Transport-Security” = “max-age=631138519”;
“x-rate-limit-limit” = 15;
“x-rate-limit-remaining” = 0;
“x-rate-limit-reset” = 1375982680;
}

Am I hitting a rate limit? Can I only make so many requests? Timeline requests for 10-15 users doesn’t seem like its asking too much…


#2

Hi there,

All API methods do have rate limits – each method its own limit. App-only auth’s rate limits are generally low, especially if you’re trying to service multiple users. Generally to scale your use of the API with the size of your user base, you’ll use user-based auth and act on each user’s behalf instead.

It looks like you’re probably using the users/show API, which looks up a single user at a time. You’ll find it easier to collect data like this with users/lookup – it lets you look up 100 users in a single request.


#3

I was using statuses/user_timeline, which translated well to users/lookup, thanks! For scaling to hundreds of users, you’re saying I MUST use user-based auth, right? Otherwise they’ll be using up the rate limits?


#4

Depending on what your needs are, maybe user timeline was what you wanted? It provides the most recent tweets by a specific user. If you just need user data, users/lookup is the way to go.

Yes – unless you’re fine running into rate limits and asking users to wait for data, or otherwise build a significant caching layer, you’ll likely need to require end users to authenticate in order to scale to that many users.