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.
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.
You can use this API (from official instagram site) to fetch username
by user static id:
GET https://www.instagram.com/graphql/query/?query_hash=c9100bf9110dd6361671f113dd02e7d6&variables={"user_id": ${user_id}}
Replace ${user_id}
with actual user id.
const username = result.data.user.reel.owner.username
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With