1080x1080 photos via Instagram API

北战南征 提交于 2019-11-28 05:22:09

[Update] After Mar 23, 2018

I used Ekrem Gurdal's answer to make it work:

The IG API gives you "link" attribute, e.g. https://www.instagram.com/p/BTduOwSAwN6/

Then you can append ?__a=1 to this e.g. https://www.instagram.com/p/BTduOwSAwN6/?__a=1

And you can extract from the json result where the high resolution photo is stored: graphsql.shortcode_media.display_url

E.g. https://instagram.fmnl2-1.fna.fbcdn.net/vp/f8f54b9fcb2bca69d7c73d9ffb232d64/5C324A1C/t51.2885-15/e35/18161146_397673830625587_2385146908864675840_n.jpg

Hope this helps. Maybe IG folks will also find a way to disable this in the future. Why do they not just include the hi-res photo in the API response, smh

[Update] As of Mar 23, 2018, workaround below doesn't work anymore.

Just to update anyone who's looking at this in 2018. The solution that worked for me is to remove the "vp/" on top of replacing the resolution to 1080x1080.

E.g.

https://scontent.cdninstagram.com/vp/41d5aee08758061976d26e48f45e673a/5ADA338E/t51.2885-15/s320x320/e35/20065394_1785212551507111_5192354829363576832_n.jpg

to

https://scontent.cdninstagram.com/41d5aee08758061976d26e48f45e673a/5ADA338E/t51.2885-15/s1080x1080/e35/20065394_1785212551507111_5192354829363576832_n.jpg

Not sure why you are getting down-voted, but no, that resolution is not returned by the API at the moment. However, it can be "guessed" from the other resolutions returned by the API, but that could change at any time. For example, given the standard resolution JSON:

  "standard_resolution": {
    "url": "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/e35/sh0.08/11370971_837216559694773_771634899_n.jpg",
    "width": 640,
    "height": 640
  }

Remove the size part (s640x640 here) and the two paths that follows (e35/sh0.08 for this picture, likely different for yours) to end up with the URL to the 1080x1080:

    https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/11370971_837216559694773_771634899_n.jpg

This has worked since that resolution was activated on my account. But again, I would just wait for the API.

As of 26th March 2018, Instagram changed their links. Here's a working solution to get 1080x1080 resolution images from API.

  1. Get the user_Id from https://www.instagram.com/{username}/?__a=1.

  2. Paste the user_id in this link https://i.instagram.com/api/v1/users/{user_id}/info/.

  3. Get the hd url link from hd_profile_pic_url_info. :)

Omiod

I noticed that simply removing the size part, the biggest image is returned:

https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/e35/sh0.08/11370971_837216559694773_771634899_n.jpg

to

https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/e35/sh0.08/11370971_837216559694773_771634899_n.jpg

Hence this should do the trick:

var hightUrl = data.images.standard_resolution.url.replace("/s640x640/","/");

You can simply fetch 1080p image if available by using this url:

https://www.instagram.com/p/['IMAGE-CODE']/?__a=1

This works as of 20th March 2018.

Remove the vp and the size parts. So if we have a 150x150 image here

https://scontent.cdninstagram.com/vp/6f28b299faab04675a936073c94d0fde/5B2E3498/t51.2885-15/s150x150/e35/c135.0.810.810/28152308_875888592619569_7505395194448052224_n.jpg

Remove /vp and /s150x150 to get

https://scontent.cdninstagram.com/6f28b299faab04675a936073c94d0fde/5B2E3498/t51.2885-15/e35/c135.0.810.810/28152308_875888592619569_7505395194448052224_n.jpg

And we can get the 1080 image here

You can even just leave the last two segments

https://scontent.cdninstagram.com/e35/28152308_875888592619569_7505395194448052224_n.jpg

which can be seen here

Hope this helps

This worked for me today (15 August 2018) for most public images. I think, because people use different apps to upload images, the API may show different sizes but the links are to the same default resolution file.

  1. Go to the user's page: https://www.instagram.com/username
  2. Click on the image you want and the URL bar will change to: https://www.instagram.com/p/image-code/?taken-by=username
  3. Copy the image-code from the URL
  4. Go to: https://www.instagram.com/p/image-code/?__a=1
  5. Scan through the JSON file (it helps to have a JSON viewer extension enabled) and click on the highest resolution image to download it. For example:

The problem with instagram image URL's is that the URL signatures provided in the json responses expire after some time. My workaround for this problem is as follows:

Steps: 1. Get the instagram post link. Eg : https://www.instagram.com/p/Bo-Jru-g7Wa/

or if you don't have the link, the instagram api provides you with a permalink(image-code) option in the result array which for the above link is Bo-Jru-g7Wa

  1. Now just add media?size=l after the url ie.,

Result: High quality image url:

https://www.instagram.com/p/Bo-Jru-g7Wa/media?size=l

you can see it in action here: https://jsfiddle.net/nmj1z7wo/fiddle URL

This link can be considered as a shorthand code to instagram image URL's which are very much bigger. Supported values for size are t (thumbnail), m (medium), l (large). Defaults to m.

You received

"standard_resolution": {
    "url": "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s640x640/e35/sh0.08/11370971_837216559694773_771634899_n.jpg",
    "width": 640,
    "height": 640
  }

It's possible to replace s640x640 with s1080x1080 or 2048x2048. Both this request return image with resolut 1080x1080

var hightUrl = data.images.standard_resolution.url.replace("s640x640","s1080x1080");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!