How can one retrieve an Instagram username from it's ID using Instagram's API or website? I have gotten a database table which contains Instagram User IDs and I need to know their usernames.
-
Welcome to SO. This site is not a code-writing service and is not meant for delivering complete solutions. Users are expected to show some effort and code whilst SO is here to help you solve specific programming problems along the way. Have you tried anything already? Please read: https://stackoverflow.com/help/asking – Maciej Jureczko Oct 04 '17 at 20:51
-
@MaciejJureczko yes I have tried several options without success. I'm not asking for the code... I'm asking if someone has already achieved this and can enlighten me with their knowledge so I can achieve it myself. – ssthormess Oct 07 '17 at 01:47
5 Answers
One can use https://i.instagram.com/api/v1/users/USERID/info (replace USERID by the user id). It returns a JSON in which the field user.username is that user's username.
With curl and jq installed, this shell oneliner will directly return the username:
curl -s https://i.instagram.com/api/v1/users/USERID/info/ | jq -r .user.username
However, keep in mind that this isn't an official API endpoint.

- 627
- 7
- 13
before continuing I would like to inform you that due to recent experiences, this "solution" is no longer available due to the latest updates in instagram api, but I hope it will contribute to something for you!
You could access the user data that you have the userId through the instagram api through the endpoint: https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN However this requires [public_content], a permission that needs to be accepted by instagram so you can explore all the "public users" of instagram, this permission is no longer being waited for by instagram.
You can learn more about the instagram endpoints here: https://www.instagram.com/developer/endpoints/users/#get_users

- 167
- 2
- 12
Instagram Graph API In 2019-08-13 Instagram had introduced Business Discovery API where it allows you to get data about other Instagram Business or Creator IG Users.
For that you need following permissions:
- instagram_basic
- instagram_manage_insights
- pages_read_engagement or pages_show_list
First of all you need to fetch your Instagram Business Id using this query
https://graph.facebook.com/v7.0/{your_instagram_id}?fields=instagram_business_account&access_token={your_access_token}
then you will get Instagram Business Id
{
"instagram_business_account": {
"id": "17841430463493290"
},
"id": "101345731473817"
}
Using Instagram Business Id and your access token you can fetch anyone's user id from username
Example:
https://graph.facebook.com/v7.0/17841430463493290?fields=business_discovery.username(zimba_birbal){id,username,followers_count,media_count}&access_token={your_access_token}
Response:
{
"business_discovery": {
"id": "17841401828704017",
"username": "zimba_birbal",
"followers_count": 166,
"media_count": 36
},
"id": "17841430463493290"
}

- 23
- 3
Need modify the user agent (instagram app's agent), and use some browser web, otherwise use wget.
wget --user-agent="Instagram 85.0.0.21.100 Android (23/6.0.1; 538dpi; 1440x2560; LGE; LG-E425f; vee3e; en_US" https://i.instagram.com/api/v1/users/*SOME_ID_INSTAGRAM*/info/
find your desidered username in file "index.html" saved
Note: to find the user ID, you can add ?__a=1 to a profile URL, for example: https://www.instagram.com/*SOME_USERNAME*/?__a=1

- 31
- 2
Data 365 Instagram API that I am currently working for seems to be a suitable tool that may help you.
Birbal Zimba has already described a number of restrictions on the official API in his answer. Instagram API from data365.co doesn't have such limits.
To get the username, you should send requests including the profile_id (the same as the user_id), namely:
POST request to download profile data:
https://api.data365.co/v1.1/instagram/profile/{profile_id}/update?access_token=YOUR ACCESS TOKEN
GET request to receive profile data:
https://api.data365.co/v1.1/instagram/profile/{profile_id}?access_token=YOUR ACCESS TOKEN
You will receive a response not only a username but also a full name, biography, profile photo, business category, user gender and age, number of followers, followings, posts, and much more.
You can see a response example in JSON here.

- 1
- 1