Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

404 Error getting JSON from Instagram Graph

I am developing an application for a client which uses the Instagram graph to search for a specific hashtag. For this I use the following JavaScript:

let rawData, resuData;
$.ajax({
url: 'https://www.instagram.com/explore/tags/dogs/?__a=1',
type: "GET",
dataType: "json",
success: function(data) {
    //console.log(data);
},
complete: function(data_response) {
    rawData = (data_response.responseText);
    resuData = JSON.parse(rawData);
    console.log(resuData);
},
error: function (error) {
console.log("Error!");
}
});    

This gives me a JSON with the data I want.

The problem comes when I want to obtain the data from the "elbaresotracosa" hashtag (https://www.instagram.com/explore/tags/elbaresotracosa/?__a=1) which shows me the message error 404 as shown in the following image.

error 404 instagram graph

But when I enter that URL from the browser itself, it shows me the JSON that I'm looking for.

instagram graph JSON

In the developer tools, from the Network tab, it says that the content-type is "application/json"

content-type: application/json

Do any of you have any idea how I can solve this problem?

like image 797
matias Avatar asked Apr 30 '26 10:04

matias


1 Answers

I have a scraper using the same endpoint and it stopped working yesterday.

I guess Instagram just blocked access to the tags explorer for unauthenticated requests.

If you're logged in you can see the hashtags, but open the same link in an incognito window and you won't (for some reason it still works for some hashtags like the #dogs one)