How do I look up screen name from id?


If I have a user’s ID, how can I use the Twitter API to look up their screen name? Is there some operation to do this which does not eat into my rate limit?


There is no endpoint that won’t count against the rate limit, but given that the rate limit is per endpoint that should not be a huge problem.
To solve your problems you can use two different lookup endpoints:


This endpoint can be used to lookup a single user ID (or screen name, both is possible). To lookup a user by it’s ID you use the user_id parameter. You should not use that endpoint to look up more than one user, as it is inefficient if you have many IDs to lookup.


This endpoint can be used to lookup a lot of user IDs (or screen names) at once. You specify the user_id parameter which you have to set to a comma separated list of ID’s.
Note that the order of user IDs may not match the order of users in the returned array, that means that you need to look inside each user object for the ID and screen name, to actually associate the ID to the screen name.
If you need to lookup a lot of users (this endpoint supports up to 100 at once) you should use a POST request instead, as else it could happen that the request URL gets too long.


Thanks! And you’re telling me each of these requests will be individually rate-limited? So /users/show won’t count against /search/tweets or /users/lookup?