Instagram how to get my user id from username?

前端 未结 24 998
傲寒
傲寒 2020-11-30 17:14

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?

相关标签:
24条回答
  • 2020-11-30 17:34

    Although it's not listed on the API doc page anymore, I found a thread that mentions that you can use self in place of user-id for the users/{user-id} endpoint and it'll return the currently authenticated user's info.

    So, users/self is the same as an explicit call to users/{some-user-id} and contains the user's id as part of the payload. Once you're authenticated, just make a call to users/self and the result will include the currently authenticated user's id, like so:

    {
        "data": {
            "id": "1574083",
            "username": "snoopdogg",
            "full_name": "Snoop Dogg",
            "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_1574083_75sq_1295469061.jpg",
            "bio": "This is my bio",
            "website": "http://snoopdogg.com",
            "counts": {
                "media": 1320,
                "follows": 420,
                "followed_by": 3410
            }
    }
    
    0 讨论(0)
  • 2020-11-30 17:35

    This can be done through apigee.com Instagram API access here on Instagram's developer site. After loging in, click on the "/users/search" API call. From there you can search any username and retrieve its id.

    {
    "data": [{
        "username": "jack",
        "first_name": "Jack",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_66_75sq.jpg",
        "id": "66",
        "last_name": "Dorsey"
    },
    {
        "username": "sammyjack",
        "first_name": "Sammy",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_29648_75sq_1294520029.jpg",
        "id": "29648",
        "last_name": "Jack"
    },
    {
        "username": "jacktiddy",
        "first_name": "Jack",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_13096_75sq_1286441317.jpg",
        "id": "13096",
        "last_name": "Tiddy"
    }]}
    


    If you already have an access code, it can also be done like this: https://api.instagram.com/v1/users/search?q=USERNAME&access_token=ACCESS_TOKEN

    0 讨论(0)
  • 2020-11-30 17:37

    I wrote this tool for retrieving Instagram IDs by username: Instagram User ID Lookup.

    It utilizes the python-instagram library to access the API and includes a link to the source code (written on Django), which illustrates various implementations of the Instagram API.

    Update: Added source code for port to Ruby on Rails.

    0 讨论(0)
  • 2020-11-30 17:39

    Most of these answers are invalid after the 6/1/2016 Instagram API changes. The best solution now is here. Go to your feed on instagram.com, copy the link address for any of your pictures, and paste it into the textbox on that page. Worked like a charm.

    0 讨论(0)
  • 2020-11-30 17:42

    Enter this url in your browser with the users name you want to find and your access token

    https://api.instagram.com/v1/users/search?q=[USERNAME]&access_token=[ACCESS TOKEN]
    
    0 讨论(0)
  • 2020-11-30 17:42

    Working solution without access token as of October-14-2018:

    Search for the username:

    https://www.instagram.com/web/search/topsearch/?query=<username>
    

    Example:

    https://www.instagram.com/web/search/topsearch/?query=therock
    

    This is a search query. Find the exact matched entry in the reply and get user ID from the entry.

    0 讨论(0)
提交回复
热议问题