Recently i wondered why instagr.am did not publish its api, especially because i assumed them to already use one. Therefore i created a wlan on my macbook, connected the iphone with it and sniffed some instagram traffic using wireshark. What i found is the following API. Then i started to develop a PHP-library for it at github.
[UPDATE] yesterday @mislav contacted me and linked me his api-documentation which is much nicer than mine 🙂 here you go: https://github.com/mislav/instagram/wiki
The base for all urls is http://instagr.am/api/v1/ – “v1” lets us expect, that they currently develop v2 which will probably be released some time. Normally instagr.am uses gzip as enc-type for communication.
The following list is not complete. You may guess other actions from the url-names, i only tested a few and only some of them made it into my PHP-library.
“pk” stands for primary key i suppose.
Action | URL | Parameters | response |
---|---|---|---|
login | accounts/login/ | username, password, device_id | {“status”:”ok”}{“status”:”failed”, “message”:”some error message”} |
user details | users/[pk]/info/ | – | {“status”: “ok”, “user”: {“username”: “xxx”, “media_count”: 0, “following_count”: 0, “profile_pic_url”: “http://xxx.jpg”, “full_name”: “xxx”, “follower_count”: 0, “pk”: pk}} |
post comment | media/[pk]/comment | comment_text | {“comment”: {“media_id”: pk, “text”: “xxx”, “created_at”: 0, “user”: {“username”: “xxx”, “pk”: pk, “profile_pic_url”: “http://xxx.jpg”, “full_name”: “xxx”}, “content_type”: “comment”, “type”:1} |
change media data | media/configure | device_timestamp=0&caption=xxx&location={“name”:”xxx”,”lng”:0,”lat”:0,”external_id”:0, “address”:”xxx”,”external_source”:”foursquare”} &source_type=0&filter_type=15 | {“status”: “ok”, “media”: {“image_versions”: [{“url”: “xxx.jpg”, “width”: 150, “type”: 5, “height”: 150}, {“url”: “xxx.jpg”, “width”: 306, “type”: 6, “height”: 306}, {“url”: “http://xxx.jpg”, “width”: 612, “type”: 7, “height”: 612}], “code”: “xxx”, “likers”: [], “taken_at”: 0, “location”: {“external_source”: “foursquare”, “name”: “xxx”, “address”: “xxx”, “lat”: 0, “pk”: pk, “lng”: 0, “external_id”: 0}, “filter_type”: “15”, “device_timestamp”: 0, “user”: {“username”: “xxx”, “pk”: pk, “profile_pic_url”: “http://xx.jpg”, “full_name”: “xxx”}, “media_type”: 1, “lat”: 0, “pk”: 0, “lng”: 0, “comments”: [{“media_id”: 0, “text”: “xxx”, “created_at”: 0, “user”: {“username”: “xxx”, “pk”: pk, “profile_pic_url”: “http://xxx.jpg”, “full_name”: “xxx”}, “content_type”: “comment”, “type”: 1}]}} |
like media | media/[pk]/like/ | – | {“status”: “ok”} |
upload media | media/upload | (multipart/form-data) device_timestamp=0 lat=0 lng=0 photo=(binary data)filename=”file” | {“status”: “ok”} |
show friend details | friendships/show/[pk] | – | {“following”: true, “status”: “ok”, “incoming_request”: false, “followed_by”: true, “outgoing_request”: false} |
show own feed | feed/timeline/? | (the last ? may be a number that defines how many elements you want to load, but i haven’t tested it so far) | what you get back is very massive (and would be a repetition), therefore only an overview:
{“status”:”ok”, “items”:[— a list of media-items (similar tothe response to changing a media —],”num_results”:0} |
show feed of a user | feed/user/? | (same as above) | (same as above) |
As i already said, there are definitely more actions that are possible. But i didn’t try everyone. I’m happy with reading from instagr.am, what is what i did at ma instagram.
I hope i can bring this api into a nice form to read in the near future.
Hope that helps someone.
Gibt’s auch sowas wie einen globalen Feed?
Hab das Ganze eingebaut, meine Gedanken dazu hier: http://www.morgenstille.at/blog/implementing-gruzillas-instagram-api/
gibts, ist aber noch nicht commited…
werde das nachholen und hier bekannt geben
Any way to get it to output XML instead of JSON?
I just tried to send an additional header:
Accept: application/xml
but it did not change anything. :/