Get user's recent media with account username instead of user ID

Viewed 2413

So I want to use the Instagram API to get a specific user's (NOT MY USER) recent media. Instagram has the following endpoint for doing so:

(GET) https://api.instagram.com/v1/users/{user-id}/media/recent/?access_token=ACCESS-TOKEN

This is a problem because I do not have the user's ID (why would I, Instagram?). What I do have is the account username (as most people would), e.g. @thisisauser.

I've been reading the API docs and I can't find an endpoint that will give me the user ID for a specific account username. I mean, yes, there is:

(GET) https://api.instagram.com/v1/users/search?q=jack&access_token=ACCESS-TOKEN

...but it doesn't do what I need it to do, which is to search for an exact match.

I've also checked out other threads on Stack Overflow and other websites. However, the alternative solutions offered are, at best, questionable.

The fact that this whole thing is an actual issue surprises me. I mean, SURELY there's a legitimate, Instagram-approved, precise and straightforward way of either:

  • obtaining a user's recent media by providing the account username (which is what people know you by... not a sequence of numbers) OR
  • obtaining a user's ID via an exact match search, with no chance of multiple possible results

FYI: I'm doing this server-side, using PHP and cURL.

Side note: If I have to make a separate request to the API in order to convert an account username to a user ID, that's just a waste of a request, one more for the hourly limit. Just an observation, in case any member of the Instagram team happens to see this.

3 Answers
Related