Link to Instagram profile with user ID
Asked Answered
O

8

18

I want to link to a profile/user account on Instagram. I have the user ID, but the I can't find the answer in the developer API documentation. I've tried instagram.com/userID and instagram.com/users/userID but these aren't working. Simple question: I have just a single <a> tag and I want to know what goes in the href to take the user to a specific instagram profile. Or possibly a window.location in javascript.

Or if there's a way to get the username from the ID, I suppose I could also do it in that round-a-bout way...

Oldtime answered 16/7, 2013 at 17:30 Comment(4)
Do you need any more help with your question or did one of the answers already help you solve it. If so, please remember to accept it. Otherwise I'll try to help.Raincoat
@TimBodeit The answers did not help. I ended up using the user name instead of ID.Oldtime
Yes there is a quick way. Answered in hereElmiraelmo
#59526637Tallulah
R
3

I am not aware of a solution, that makes it work as a simple link.

You will need to use the Instagram API and sign up your application so that you have a Client-ID.

Next, you will need to do the following request as HTTP GET:

https://api.instagram.com/v1/users/userID?client_id=YourClientID

This will return a JSON-Result, which will contain the username inside the data section.

Now you can use http://instagram.com/username as your link.

Raincoat answered 16/7, 2013 at 23:32 Comment(1)
For redirecting to the IG user's webpage, the https://instagram.com/username seems to work well nowadays...Subspecies
H
2

try

async function insta(uid) {
  let api = `https://i.instagram.com/api/v1/users/${uid}/info/`
  let info = await (await fetch(api)).json();
  return `https://www.instagram.com/${info.user.username}`;
}

async function go() {
  let url = await insta(userId.value);
  link.innerText = url;
}
Type instagram user id:
<input id="userId" value=182805585 />
<button onclick="go()">Find username</button><br>
<pre id="link"></pre>
UPDATE

According this starting form 03.12.2019 above solution stops works and returns only

{“message”: “useragent mismatch”, “status”: “fail”}

instead you can try to send request GET

https://i.instagram.com/api/v1/users/1791879548/info/

with following user-agent header:

Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Instagram 105.0.0.11.118 (iPhone11,8; iOS 12_3_1; en_US; en-US; scale=2.00; 828x1792; 165586599)
Heartburning answered 7/5, 2019 at 22:15 Comment(0)
I
1

1st Method

<a href="http://instagram.com/_u/{USERNAME}/">Link to Instagram Page</a>

  • Ask user to select application to launch with

2nd Method

<a href="instagram://user?username={USERNAME}">Link to Instagram Profile</a>

  • If user installed instagram application : Directly launch page with native application
  • If user not installed instagram application : Do nothing

Tested on Android 4.4 Chrome

Inaptitude answered 9/5, 2015 at 4:33 Comment(2)
instagram://user?id={user_id} confirmed to work on iOSLathrope
does not answer OP's question : link the profile with only user IDLawrence
E
0
https://www.instagram.com/p/" . $social_id . "/"
Exemplary answered 22/10, 2022 at 11:32 Comment(0)
J
0

async function insta(uid) {
  let api = `https://i.instagram.com/api/v1/users/${uid}/info/`
  let info = await (await fetch(api)).json();
  return `https://www.instagram.com/${info.user.username}`;
}

async function go() {
  let url = await insta(userId.value);
  link.innerText = url;
}
Type instagram user id:
<input id="userId" value=182805585 />
<button onclick="go()">Find username</button><br>
<pre id="link"></pre>
Jerkin answered 3/1, 2023 at 7:15 Comment(0)
D
0

async function insta(uid) {
  let api = `https://i.instagram.com/api/v1/users/${uid}/info/`
  let info = await (await fetch(api)).json();
  return `https://www.instagram.com/${info.user.username}`;
}

async function go() {
  let url = await insta(userId.value);
  link.innerText = url;
}
Type instagram user id:
<input id="userId" value=182805585 />
<button onclick="go()">Find username</button><br>
<pre id="link"></pre>

arifa_a235668

Duleba answered 14/4, 2024 at 17:32 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Cotquean
B
-1

async function insta(uid) {
  let api = `https://https://instagram.com/priyasharma_officle?igshid=MzRlODBiNWFlZA==

> *

Blockquote

*

/api/v1/users/${uid}/info/`
  let info = await (await fetch(api)).json();
  return `https://www.instagram.com/${info.user.username}`;
}

async function go() {
  let url = await insta(userId.value);
  link.innerText = url;
}
Type instagram user id:
<input id="userId" value=https://instagram.com/priyasharma_officle?igshid=MzRlODBiNWFlZA==/>
<button onclick="go()">Find username</priyasharma_officle><br>
<pre id="link"></pre>
Brouwer answered 24/8, 2023 at 4:47 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Cotquean
M
-11

You can also use this: https://instagram.com/user/?id={USER_ID}

Mascle answered 22/7, 2015 at 20:52 Comment(1)
no, this just link to the funny guy who chose username "user", you can try any id you would like, still the sameLawrence

© 2022 - 2025 — McMap. All rights reserved.