There is currently no way to get all post URLs for an Instagram profile using the oEmbed API based on the documentation (or anywhere else on the web). You'll have to get all of the post shortcodes (links) by:
- Do a GET request to
https://www.instagram.com/{profile_handle}/?__a=1
. There is a very strict rate limit these days, so it is highly recommended to cache the results the first time, maybe with local storage.
- The result will be a JSON object with all of the profile info if the profile is public. You can check of the requests profile is public by checking the
[data].graphql.user.is_private
- For each
[data].graphql.user.edge_owner_to_timeline_media.edges.node
, get the shortcode
property.
- Finally, create your dynamic post URI
https://www.instagram.com/p/{shortcode}
.
Alternatively, you could do a GET request to `https://www.instagram.com/{profile_handle} and use regex to get the a similar JSON object containing profile data in the HTML response like so:
const uri = `https://www.instagram.com/${handle}/`;
const instaRes = await axios.get(uri);
const html = instaRes.data;
const regex = /_sharedData = (.*);<\/script>/m;
const json = JSON.parse(regex.exec(html)[1]);
The rate limit is strict here too so use be sure to cache. Testing can be a pain because you may have to change your IP address a couple times when you hit the rate limit.