instagram-api

Instagram how to get my user id from username?


I'm in the process of embedding my image feed in my website using JSON, the URL needs my user id so I can retrieve this feed.

So, where can I find/get my user id?


Solution

  • 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