Hi, I’ve been testing out the the v2 Users Lookup endpoint and it’s not working consistently, however when I switch to v1.1 then it works. Here’s what I tried and the error code:
(ps: I used python and the requests library)

  • I tried requests.request("GET", "https://api.twitter.com/2/users/406533892", headers=headers) this works successfully, giving me a 202 response code with the users id, name and username.

  • I then tried

requests.request(
    "GET", 
    "https://api.twitter.com/2/users/406533892&user.fields=username,name,created_at,location,verified,public_metrics",
    headers=headers)

this however fails giving me 404 response code.

  • I also tried
requests.request(
    "GET", 
    "https://api.twitter.com/2/users/?ids=406533892,2848603625",
    headers=headers)

this also fails and gives a 404 status code.

Now when I use the v1.1. endpoint:

requests.request(
    "GET", 
    "https://api.twitter.com/1.1/users/lookup.json?user_id=406533892,2848603625",
    headers=headers)

It works perfectly returning a 202 status code and gives me username, name, tweets, followers_count, etc.

This should be with an ? not a & because it’s the first parameter, so

"https://api.twitter.com/2/users/406533892?user.fields=username,name,created_at,location,verified,public_metrics"

as the url should work

"https://api.twitter.com/2/users/?ids=406533892,2848603625"

Should be

"https://api.twitter.com/2/users?ids=406533892,2848603625"

(there was an extra slash / between users and ?)

Those should work!

2 Likes

Wow I feel so silly, haha thanks so much, everything works perfectly now!

1 Like