Instagram API

Dear Lazyweb, is there a reverse-engineered Instagram API that doesn't suck?

Instagram's official API has no mechanism for uploading photos, because YOU HAD ONE JOB. So if you want to automate anything, you head into the salt mines. Which of course I did: instagram-api.

But I am sick to death of playing whack-a-mole with their API changes. I do not enjoy this work. It brings me no joy. Current pain in the ass: I'm getting tripped up by their "unusual login" checks. This game of whack-a-mole is harder than, say, Youtube's, because some time in the last year mitmproxy stopped working against either iOS Instagram, or against Android Instagram running in an emulator, because why I don't know why.

So there's this other API, and it has two things to recommend it:

  1. It seems to mostly work, and
  2. I am not the maintainer.


  1. It's written in PHP, which makes me just kind of assume that it's also a rootkit;

  2. It has a list of dependencies as long as your arm (it's over 101,000 lines of code! Mine is like 2,500, WTF. That thing has like a hundred different "exception" classes alone.)

  3. Installing it requires this thing called "composer", which is apparently Yet Another Package Manager for PHP libraries, and it is, as far as I can tell, a literal rootkit. Here's how you can tell: it's installation instructions are to pipe a PHP URL into a root shell. So uh, no thanks.

I mean, I guess I could run it inside a virtualized host running on my colo machine or some shit, but that sounds hard and slow and I don't want to figure that crap out.

Are there any other options?

And if there aren't, are any of you using my script, and if so, can you just fucking fix it for me? Because aaauuugggghhhh I have better things to do than working around yet another stupid fucking lock-in-based business model.

Or, you know, other options include:

  1. Hire another full-time employee to manually do all the crap that I've already automated;
  2. Decide that it's cool for my business to have no social media presence.

In short, fuck you, Instagram, Facebook and Twitter. A pox on all your houses.

Previously, previously, previously, previously, previously, previously.

Tags: , , , ,

25 Responses:

  1. helix says:

    Instagram really does suck at publishing anything useful. I guess they think they need the monopoly on apps that can actually publish content.

    This library however, is actually quite good - used it myself.
    Composer on the other hand took me quite a while longer to get used to. I normally prefer downloading from GitHub and installing libraries like this one myself.. Recently though, composer has definitely become the standard way to manage package dependencies in PHP... it's the community standard, basically as popular as npm for node. well not really but it's the main one so you get the point.

    Basically, this library and composer are innocuous. Yes PHP is my preferred language of the dozen or so i have to use on a weekly basis.

    Cheers for the great blog.

    • jwz says:

      "The PHP community has collectively decided that the Composer rootkit is relatively innocuous" is not the ringingest of ringing endorsements.

  2. Kyle Huff says:

    “There is only one really serious philosophical problem,” Camus says, “and that is suicide."

  3. erlogan says:

    If you are willing to toss money at this problem, there's for scheduling social media posts, and they're an "Instagram Partner" so I guess blessed to do this sort of thing.

    • jwz says:

      I'm willing to toss money at the problem, but as far as I can tell, that site does not have an API of any kind. So it replaces the problem of "unable to automate posts to Instagram" with "unable to automate posts to Later".

      Ok, I can click ten thousand times all at once instead of having to spread that out through the month, but that's not actually a solution to the problem I'm trying to solve.

  4. Karellen says:

    "Decide that it's cool for my business to have no social media presence."

    As someone very wise once said - "You can do it. I believe in you!"


  5. Cowmix says:

    This might be a perfect situation to utilize Docker.. You can bundle all the dependencies into a container, run it with almost zero overhead while having almost acceptable security.

  6. margaret says:

    I tried doing the same (write a CLI to post on instagram) and realized "fuck these guys." The content I would want to post is not native to my mobile I went the "no social presence" route. Your request had me look again and it seems someone's done a Python port of the PHP code you mention. I didn't try posting anything but the './examples/' worked and gave 'useful' information back. Too, this has changed since the last time I looked. I'm guessing it will be in eternal-beta-mode as its sole purpose is to shut up anyone asking for an API.

    • GDR! says:

      I'm using the Python library for automated cross posting to different social networks, it's okay. I'm not sure how well it works without moviepy if you don't need videos, if it does - the only dependency is python-requests.

  7. Ed says:

    It's hard to convey how much I enjoy your perl code. I know that perl is "not cool" but I'll be damned if it isn't the swiss army chainsaw I still grasp for like 90% of my non statistics needs.

    • jwz says:


      Though I don't really know what to make of this statement since every line of it that I write should probably be captioned SCREAMING INTERNALLY.

      I guess if the only good thing that comes of all this Perl I've puked out over the years is that some people realize "Hey, you can write Perl like C and it's actually readable if you do that", then something good came of it I guess?

  8. Kaleberg says:

    I've often been reduced to browser scraping. Sometimes I use which looks like, except it drives a browser. Sometimes I just use a Webkit interface and write actual Objective-C code to bang on Javascript and the browser state. This has two advantages which ever so slightly alleviate the misery. One is that code can recognize those "unknown browser" problems and let me deal with the stupid text message manually and hope it doesn't bother me again too soon. Second is I can use delegates to grab raw data objects like images or PDFs as binary blobs.

    I agree. This is wretched. There should just be some simple APIs.

  9. oleg says:

    Maybe it's time to do something else about it? Join fediverse, promote your events on and post your pictures on one of mastodon instances:

    • jwz says:

      Do you people just not understand that we are competing with other venues for artists?

      "Oh hey, we've decided to not advertise in any of the standard places but only on these fringe nerd sites you've never heard of. It means you can expect way less attendance at your show because nobody will find out that it's happening, but let me show you a manifesto."

      "Oh absolutely," they will not say, "I will totally hitch the wagon of my goddamned gas money to the star of your principles."

      Every time one of you people has the great idea of "why don't you just not advertise" yours saying "why don't you just close up shop even earlier than you would need to otherwise."

      The hundred people I'm gonna need to fire when we close thank you for fucking right off.

      • oleg says:

        But I didn't suggest you to stop advertising in standard places. Just add these nerd sites as well. They usually have well defined API, and if people like you don't start using them, they stand no chance against fb/twitter/instagram etc.

  10. sal says:

    I'm not running a business but the amount of effort to automate the social media content of my kid's school's web site is unreal. I'm using scripts, wordpress plugins, IFTTT and there is still way to much manual work.

    The ideal workflow is:

    1) Article is written in wordpress and is published
    2) A tweet is sent out
    3) A facebook post is sent out
    4) Hero image becomes an Instagram post with a link back

    The actual workflow is:

    1) Article is written and published in wordpress
    2) A tweet is sent out with two levels of redirection back to wordpress, because fuck you
    3) A facebook post is made but less than 1/4 of people who want to see it will see it because it isn't promoted
    4) An email is sent out asking that an Instagram post is made. The parent who gets this email will fuck up this basic task even though they've done it 100 times.
    5) A webhook is called by IFTTT and a script is run to compare text from facebook page with wordpress to alert me if suck. This happens about 20% of the time because fuck you
    6) Email list gets a message asking admins to verify Twitter and Facebook because suck
    7) A script send me the links to the analytics so I can track the activity when I get back. Holes in the analytics mean something didn't run or a social media policy changed

    This sucks but having to deal with this shit because it feeds your family and the families of dozens of employees sounds so much fucking worse.

  11. Having used mitmproxy recently for similar purposes, I feel your pain. It’s definitely an arms race against the corporations, and things like certificate pinning being used by mobile apps provides yet more hurdles.

    If you’re conceiving hiring a person to do the work you want automated, why not offer a “bug bounty,” or something? I have no idea the tax implications or whether there’s any risk involved in hiring somebody to possibly violate Instagram’s TOS.

  12. oes says:

    Since you already have a business account for the DNA Lounge on Facebook, you can use the Graph API:

    • jwz says:

      That API is a fucking joke. I mean, yes, I guess it could laughably be called "progress", but among other failures, it doesn't let you post videos or stories. I mean, why would it, videos are so five years ago. Also, how smoothly do you imagine that this part is going to go when I send them a link to a pile of Perl code:

      If you are able to use your app in the Graph API Explorer and successfully pull data from your Instagram Business Account, you can submit your app for review.

      When Facebook asks you to "submit an app for review" they want you to upload a screencast of the app "in use". And they reject it when you send them a video of you typing "crontab -l". Guess how I know this.

  13. __ghost__0_0__ says:

    Do you know it's actually fairly trivial to to post to the instagram from the desktop if you spoof a mobile user agent in your browser? Automating that with Phantomjs or whatever might prove to be the least suicideboothy option.

    • jwz says:

      That's an interesting theory, and if you point me to a script that does this thing and can be run from cron, I will totally try it out.

  • Previously