Instagram media by account in JSON

July 8th, 2017

Scraping inline JSON for fun and frustration

This will work until Instagram go ahead and make changes to their JS objects. Until then, go crazy.

So... within the Instagram page source is a SCRIPT tag that contains pretty much everything (almost) that you'd need to make a feed of your most recent Instagram posts. Its all within inline JS that isn't terribly awkward to parse out.

With that in mind, this is a quick demo to pull images with a comma-delimited list of Instagram usernames.

The PHP code is here:

Just follow the steps in the to setup a local debug server and then you can run this in your browser:


Again, disclaimers about making sure you add better error reporting and if Instagram/Facebook change their code then this will need patching.