'How do I get Instagram posts from several accounts?

I would like to show the latest instagram posts from three different instagram users in one app. I control the instagram accounts, so it wouldn't be a problem to use APIs that require the user to accept access.

One method would be to add ?__a=1 at the end of their profile to get at json that contains this information, show the title as text in my app and load the picture from Instagram's CDN.

From what I can see, this isn't allowed by Instagram's terms, so I could easily see them banning the whole thing after some time.

Using Instagram's APIs (both Basic Display API or Graph) looks doubtful in an app, since they are based on tokens that should be kept server side.

Potentially I can configure a backend that does nothing but get the content, stores it with the single purpose of pushing it forward. I would think even this is against Instagram's terms, and sounds a bit over-kill.

Is there any methods I've missed?

(The Bot asked for some code, here's the JS I cannot use..)

    function viewInsta(input_url) {
var url = input_url;
const p = url.split("/");
var t = '';
for (let i = 0; i < p.length; i++) {
if(i==2){
t += p[i].replaceAll('-', '--').replaceAll('.','-')+atob('LnRyYW5zbGF0ZS5nb29n')+'/';
} else { if(i != p.length-1){ t += p[i]+'/'; } else { t += p[i]; } }
}
// document.getElementById(this.id).src = encodeURI(t);
return '<img src="'+encodeURI(t)+'">';
}


var request = new XMLHttpRequest();
request.open("GET", "instagram.json", false);
request.send(null)
var my_JSON_object = JSON.parse(request.responseText);
var node_objects =  my_JSON_object.graphql.user.edge_owner_to_timeline_media.edges;

node_objects.forEach(alert_function);

function alert_function(value){
var url_array = value.node.thumbnail_src.split('?');
var url = url_array[0];
document.getElementById("div1").innerHTML += value.node.thumbnail_src + viewInsta(value.node.thumbnail_src) + '<hr>';
console.log (value.node.thumbnail_src);
}


Solution 1:[1]

You'll need to use the Facebook Graph API, specifically Instagram, and do the calls from your backend.

https://developers.facebook.com/docs/instagram-api/reference/ig-user/media#get-media

This means you'll need to do oAuth and store the access tokens on your backend.

You should be able to get the posts with POST /{ig-user-id}/media

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MadsW