Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the real HQ image from the Instagram API?

Firstly, there are already questions to this topic, but none cover up my problem, entirely, because it's either not the data I need or it's not working properly.

There are services like InstaDP that are able to show you the HQ version of any profile picture from Instagram. Now, I wonder how this is possible?

I did some research and were able to find a higher quality URL when accessing https://www.instagram.com/instagramforbusiness/?__a=1 (see profile_pic_url_hd, answered here). However, InstaDP seems to have a backend that returns a different url that redirects to a way higher quality image: https://instadp-cors-222621.appspot.com/get-hd?id=1107766105 (see at hd_profile_pic_url_info, I extracted the ID for the URL from the result of the ?__a=1 link). I tested this with my personal profile and was able to get the image of myself in an outstanding quality of 1024x1024. However, the ?__a=1 link seem only to return a link for my profile picture in 320x320.

Since InstaDP seem to not be the only player who is able to fetch HQ profile pictures I went ahead and compared the backends of those players. It seems that each service seem to have a different URL to the HQ profile picture of the same Instagram account. So my conclusion is that the Instagram API is involved in all that.

So I created a client key at https://www.instagram.com/developer/. I was also able to get my auth token and determine my logged in csrftoken for the X-CSRFToken header. Now my question is how to continue?

I found a few answers to this topic stating I should request https://i.instagram.com/api/v1/users/1107766105/info/, but it always returns the login page as HTML.

I tried a REST client that uses my Chrome cookies and logged into Instagram before, I tried to set my HTTP headers to X-CSRFToken:<mycookietoken> and Content-Type:application/json. (If I don't set the CSRFToken it errors, so I need to add it, but if the header is set I get the HTML again, even when the CSRFToken is correct. I don't get an error when the CSRFToken is wrong.)

I also tried setting the Origin, Referer and Host to trick Instagram in believing the request came from its own window location, without luck. Setting the Host will even cause a 400 bad request. Even adding my access token in the URL had no effect (?access-token=########).

To sum my question up, how do those services obtain the profile pictures in a such a great quality of up to 1024x1024 from the cdninstagram servers?

like image 690
Martin Braun Avatar asked Jan 21 '19 16:01

Martin Braun


People also ask

How do you see original photos on Instagram?

Go to Instagram's website on your mobile or PC browser (any browser will work), and then log in with your credentials. As you can't click on a picture directly from your feed, visit the user's profile, and then open the photo that you want to see. Hit Enter, and you'll see the picture in full size.

How does Insta DP work?

InstaDP works by allowing you to download the profile picture of the person you are following. This will help you share your full-size images with friends and family. It can also download other people's profile pictures. So, this app will help you share your profile picture and make it available for downloading.

Can you post to Instagram from API?

Today, we are launching a new feature on the Instagram Graph API Platform to make it easier for businesses to publish content. With this feature, Instagram Business accounts can schedule and publish posts to their Instagram Feeds from third-party platforms.


1 Answers

Although I am late, but this might be of someone's help:

Step 1: First thing you need to get HD Instagram profile picture is their profile ID. This can be found in the source code of user profile link. For example if you view source of the following link https://www.instagram.com/abdulhaq0/ and search for "logging_page_id" you will get "profilePage_1285389476". The numbers following the profilePage are the ID for this account.

Step 2: Next you need put ID in the following URL https://i.instagram.com/api/v1/users/{ProfileID}/info/ and open it in browser. In our case link would be https://i.instagram.com/api/v1/users/1285389476/info/

Step 3: Now on the link above search for "hd_profile_pic_url_info". There you can get the URL of HD Instagram profile picture.

Hope this helped.

like image 191
Abdul Haq Avatar answered Sep 28 '22 00:09

Abdul Haq