Is there CURRENTLY anyway to fetch Instagram user media without authentication?
Asked Answered
C

2

10

Until recently there were several ways to retrieve Instagram user media without the need for API authentication. But apparently, the website stopped all of them.

Some of the old methods:

And some old related questions are:

I was able to retrieve the first twenty items by crawling the webpage of the user, but this is not a good or standard method especially when Instagram is not supporting it officially.

I was wondering If you know any method that currently works?

Cantoris answered 16/4, 2018 at 7:49 Comment(2)
Check out this answer, it does not require any authentication: https://mcmap.net/q/138366/-how-to-perform-unauthenticated-instagram-web-scraping-in-response-to-recent-private-api-changes. However, for me its not feasible as it requires two separate requests: one to get the "rhx_gis" secret from the page's source code and another one to get the actual JSON data...Bari
Check my latest working solution here https://mcmap.net/q/135295/-how-can-i-get-a-user-39-s-media-from-instagram-without-authenticating-as-a-user I've updated my old method with new CORS proxy by Google.Tare
C
11

Unfortunately, Instagram stopped many of its APIs, including the ones that require authentication. It states in https://www.instagram.com/developer/:

To continuously improve Instagram users' privacy and security, we are accelerating the deprecation of Instagram API Platform, making the following changes effective immediately.

Some links explaining the details and causes of these changes:

Some unofficial crawling methods have been proposed in (suggested by @Louis B.) https://mcmap.net/q/138366/-how-to-perform-unauthenticated-instagram-web-scraping-in-response-to-recent-private-api-changes. You should take into consideration that these methods are being transformed each week. Therefore, I definitely prefer to use the private API.

Update 2018:

The old public API (without auth) is working again. We can access by adding ?__a=1 to the end of a profile url, like this:

https://www.instagram.com/leomessi/?__a=1

Update June 2022

The old API '?__a=1' has stopped working again. It seems to be due to an error. The page redirects to the login page as a guest. If you open it after logging in, it shows a weird error:

for (;;);{"__ar":1,"error":1357004,"errorSummary":"Sorry, something went wrong","errorDescription":"Please try closing and re-opening your browser window.","payload":null,"hsrp":{"hblp":{"consistency":{"rev":1005648797}}},"lid":"7106751273377983967"}

Update December 2023 (requires valid auth cookies)

The following link works and returns json (both parameters are required)

https://www.instagram.com/leomessi/?__a=1&__d=dis
Cantoris answered 21/4, 2018 at 4:43 Comment(12)
can you link to Instagram's "private" API? I wasn't aware such a thing existed.Inclusive
@ReactingToAngularVues Start here: instagram.com/developer example: instagram.com/developer/endpoints/usersCantoris
I don't believe that's a "private API". That's Instagram's now deprecated public API.Inclusive
"A private API is an interface that opens parts of an organization’s backend data and application functionality for use by developers working within (or contractors working for) that organization." — again, with more emphasis, what you are linking to is Instagram's deprecated, public API.Inclusive
The private-ness/public-ness of an “API” is not determined by which data it can access, but by who can access it. It doesn’t matter if the API can perform mass updates on entire user data, if it’s a publicly accessible, documented API, it’s called a “public API”. A private API is an internal or undocumented set of access points designed for the company who developed the API only.Inclusive
Check my latest working solution here https://mcmap.net/q/135295/-how-can-i-get-a-user-39-s-media-from-instagram-without-authenticating-as-a-user I've updated my old method with new CORS proxy by Google.Tare
something happen with this method, after 300 requests pear day to that url , instagram block youCockleshell
Hi, does anyone know how to deal with the issue that the images returned from instagram.com/leomessi/?__a=1 is not loading due to CORS.Synoptic
@KhushiRaval Did you find any way to deal with CORS issue?Dullish
@Dullish - I have replaced mentioned API with Instagram basic display API with authentication to resolve issues and get proper data. Refer - developers.facebook.com/docs/instagram-basic-display-apiSynoptic
The latest solution works only if you are logged...Feuchtwanger
It looks like the December 2023 link is now broken :(Julie
A
0

In Flutter/dart this solution works for me:

String url = "https://www.instagram.com/";
String userName= "instaUserName";

var res = await http.get(
Uri.parse(Uri.encodeFull(url + username + "/?__a=1&__d=dis"))); 
// adding /?__a=1&__d=dis at the end will return json data

var userProfileInfo = json.decode(res.body);
print(userProfileInfo  ); 
Agbogla answered 14/9, 2023 at 7:58 Comment(1)
This solution only works if I'm a logged user... only for me?Feuchtwanger

© 2022 - 2024 — McMap. All rights reserved.