Instagram get username from userId

前端 未结 3 1414
小鲜肉
小鲜肉 2021-02-09 05:34

I have the ability to get userId from username, but I do not have the ability to get username from userId.

I have a database of userId because that is all my app needed

相关标签:
3条回答
  • 2021-02-09 05:43

    Instagram exposes a User Endpoint for that. From http://instagram.com/developer/endpoints/users/#get_users, you can use:

    https://api.instagram.com/v1/users/(user id)/?access_token=ACCESS-TOKEN

    The response is JSON and the data you want is data.username

    0 讨论(0)
  • 2021-02-09 06:01

    Here is a way to find an Instagram username by user ID without using an access token and without the need to log in to Instagram. You first have to change your user agent to something like Instagram 85.0.0.21.100 Android (23/6.0.1; 538dpi; 1440x2560; LGE; LG-E425f; vee3e; en_US). If you want to find a username on a web browser instead of a command line tool like cURL, you can use an open source browser addon like Header Editor on Firefox (https://addons.mozilla.org/en-US/firefox/addon/header-editor/) to send this user agent only on the domain name i.instagram.com. Then you can access an URL like https://i.instagram.com/api/v1/users/5995367/info/ (replace the user ID with the one you want)

    This URL returning JSON is from Instagram private API, which is used by the Instagram mobile app and third-party apps like IG:dm. If you log in to Instagram web version, this URL will return more data. Searching a username by user ID can be useful to find a user changing frequently usernames, in case you did not already send them a message or follow them.

    Note: to find the user ID, you can add ?__a=1 to a profile URL, for example: https://www.instagram.com/alanarblanchard/?__a=1

    This URL returning JSON also was used when you clicked on a user profile with Instagram web version.

    0 讨论(0)
  • 2021-02-09 06:03

    use this API:

    https://api.instagram.com/v1/users/<USER-ID>/?access_token=ACCESS-TOKEN
    

    The response will have username and other user information, here is documentation: http://instagram.com/developer/endpoints/users/#get_users

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