How to extract Instagram Profile picture using instagram API in android ? Or any other Method To extract Insta Profile Picture?
Asked
Active
Viewed 5.1k times
3 Answers
49
By May 2023, to get Instagram profile URL via API, use this:

Chhaileng
- 2,428
- 1
- 27
- 24
-
2It is not giving me data if I am not logged into Instagram – Shrijan Regmi May 23 '21 at 13:39
-
@ShrijanRegmi sometimes you need to specify some headers like User-Agent. Eg. `curl -s -H 'User-Agent: 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)' 'https://www.instagram.com/USERNAME/?__a=1'` – Chhaileng May 23 '21 at 14:33
-
1Neither of these appear to work anymore as of Sep 10, 2021. Perhaps instructions are missing from the answer but more likely instagram has disallowed these APIs – Daniel Kats Sep 10 '21 at 20:07
-
https://www.instagram.com/USERNAME/?__a=1 This is not working in my app. This link returns as error HTML code, – Krupali Shingala Apr 25 '22 at 11:55
-
3as of recently instagram doesn't allow the use of the public API, I've tried it for multiple times all it returns is a redirect to the actual profile – unknown989 Jun 05 '22 at 21:12
-
1use https://www.instagram.com/
/?__a=1&__d=1, it should work. – Vikrant Bhat Apr 05 '23 at 16:35 -
The currently latest noted answer https://www.instagram.com/USERNAME/?__a=1&__d=1 does not work for me since it blocks my access via server. It seems to be a CORS limit blocking data access from other servers (including Postman). – Terry Windwalker Jun 09 '23 at 14:59
-
OK, perhaps not CORS but it requires a token. It says `{"message":"Please wait a few minutes before you try again.","require_login":true,"status":"fail"}` so probably a valid Instagram access token is required. – Terry Windwalker Jun 11 '23 at 08:54
14
To get profile photo, use the function bellow:
function getPhoto(a) {
// validation for instagram usernames
var regex = new RegExp(/^(?!.*\.\.)(?!.*\.$)[^\W][\w.]{0,29}$/);
var validation = regex.test(a);
if(validation) {
$.get("https://www.instagram.com/"+a+"/?__a=1")
.done(function(data) {
// getting the url
var photoURL = data["graphql"]["user"]["profile_pic_url_hd"];
// update img element
$("#photoReturn").attr("src",photoURL)
})
.fail(function() {
// code for 404 error
alert('Username was not found!')
})
} else {
alert('The username is invalid!')
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<img src="" id="photoReturn">
<br><br>
<input type="text" id="usernameInput">
<button onclick="getPhoto($('#usernameInput').val().trim())">Get profile photo</button>

Rodrigo Vieira
- 165
- 1
- 4
-
2Question was tagged with Java and Android, this is HTML and Javascript – Olav Kokovkin Dec 10 '19 at 00:12
-
4
-
2
1
Using the Instagram API users endpoint (https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN
) you will receive a response like this one:
{
"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
}
}
Using this you can get the profile picture.

Ishara Madhawa
- 3,549
- 5
- 24
- 42
-
-
Easily Get USER ID and User Details using this: `https://api.instagram.com/v1/users/search?q=[ USER NAME ]&client_id=[ YOU APP Client ID ]` for an example : `https://api.instagram.com/v1/users/search?q=isharamadhawa&client_id=[enter your id]` – Ishara Madhawa Apr 29 '18 at 13:27
-
-
-
-
Check [this](https://stackoverflow.com/questions/37609974/instagram-api-the-access-token-provided-is-invalid) – Ishara Madhawa Apr 29 '18 at 14:31
-
I have added public content scope while getting token and its in Sandbox mode – Yash Arora Apr 29 '18 at 14:35
-
1You should post another Question regarding your specific issue. I think you have received an answer for what you have posted here. – Ishara Madhawa Apr 29 '18 at 14:39
-
-
1@IsharaMadhawa This answer is no longer accurate since this API no longer provides `full_name` or `profile_picture` fields as per https://developers.facebook.com/docs/instagram-basic-display-api/reference/user. The link to the API in the answer is also dead. – Daniel Kats Sep 10 '21 at 20:13