How to Get a User's Instagram Feed

How can I get a user's media from Instagram without authenticating as a user?

This is late, but worthwhile if it helps someone as I did not see it in Instagram's documentation.

To perform GET on https://api.instagram.com/v1/users/<user-id>/media/recent/ (at present time of writing) you actually do not need OAuth access token.

You can perform https://api.instagram.com/v1/users/[USER ID]/media/recent/?client_id=[CLIENT ID]

[CLIENT ID] would be valid client id registered in app through manage clients (not related to user whatsoever).
You can get [USER ID] from username by performing GET users search request:
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]

Instagram how to get my user id from username?

Update in Jun-5-2022, Instagram API no longer use Bearer Token for authentication. But I find another useful API. All you need is added extra header X-IG-App-ID with "magic value".

https://i.instagram.com/api/v1/users/web_profile_info/?username=therock

Use can use my docker container Insta-Proxy-Server to bypass the authentication.

https://hub.docker.com/repository/docker/dockerer123456/insta-proxy-server

Demo video (I just run directly from source code): https://www.youtube.com/watch?v=frHC1jOfK1k


Update in Mar-19-2022, the API is require login now. Sorry for the bad news.

But we can solve this problem in two ways.

  1. Using my C# lib, login using your account (without any Instagram app token stuff and graph api.)
  2. In case the lib failed (I'm no longer maintain it long time ago), create a proxy server with logged in instagram account.

[Your app] --> [Proxy server] --> [Instagram] --> [Proxy server] -(forward)-> [Your app]

For Proxy server, you can use Nodejs app which install Chromium headless module (Puppeteer for example), logged in with an instagram account.

Proof of concept:

https://www.youtube.com/watch?v=ZlnNBpCXQM8

https://www.youtube.com/watch?v=eMb9us2hH3w


Update in June-20-2019, the API is public now. No authentication required.


Update in December-11-2018, I needed to confirm that this endpoint still work.

You need to login before sending request to this site because it's not public endpoint anymore.


Update in Apr-17-2018, it's look like this endpoint still working (but its not public endpoint anymore), you must send a request with extra information to that endpoint. (Press F12 to open developer toolbar, then click to Network Tab and trace the request.)


Update in Apr-12-2018, cameronjonesweb said that this endpoint doesn't work anymore. When he/she trying to access this endpoint, 403 status code return.


You can get user info when a request is made with the url below:

https://www.instagram.com/{username}/?__a=1

E.g:

This url will get all information about a user whose username is therock

https://www.instagram.com/therock/?__a=1

How to display my Instagram feed on my website?

Unfortunately, Instagram has make it harder to get user media. All public method are not working every time anymore.

My suggestion is when someone visited your website, you can use the old token to generate a new token and store it somewhere for next visit.

source: https://developers.facebook.com/docs/instagram-basic-display-api/reference/refresh_access_token

Is There a Way to Display a Specific User's Instagram Feed?

Using the following URI from the Instagram API, you can get any users feed if you know their user ID.

https://api.instagram.com/v1/users/{USER_ID}/media/recent/?client_id={CLIENT_ID}

How do I fetch my own Instagram media feed

You would want to use self feed endpoint.

https://www.instagram.com/developer/endpoints/users/#get_users_self

https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN



Related Topics



Leave a reply



Submit