1.0.0 • Published 7 years ago

instagram-plus v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

This is small library that digs into some interesting parts of Instagram's private API. The public one is great for most uses, but requires approval from above to leave sandbox mode and doesn't offer a lot of the features regular users of the app would expect. Their walled-off one gets us access to things like direct messages, geolocation for other users photos (removed from the app altogether since the most recent update), tagged photos of a given user, and news feed. It also gives us a peek at some of the cool stuff they're doing with search and smart recommendations. I threw this together after reading their great engineering blog.

A few notes:

To get started, you'll need to extract the unique access token generated by your mobile device. I've written a short tutorial on how to get it HERE.

There's only limited support for post requests. It looks like Instagram combats API abuse by signing most post req's with a unique hash that keeps it from being replayed elsewhere. You could get around this if the body or target user of your request is identical every time, such as liking and un-liking the same picture repeatedly, following/unfollowing the same user, or posting the same comment on multiple pictures.

Callbacks have the standard request callback signature (error, response, body).

Any response longer than 15 records typically (but not always) comes back paginated. You can easily traverse the collections by checking the more_available bool property and passing the value of next_max_id string into your next request. Most will accept an optional next argument.

Setup:

var instagram = require('instagram');
var client = new instagram();

/* a custom user agent is optional -
defaults to 'Instagram 8.0.0 (iPhone8,1; iPhone OS 9_3; en_US; en-US; scale=2.00; 750x1334) AppleWebKit/420+' */

client.config({
	cookie: ACCESS_TOKEN
	user_agent: USER_AGENT
});

Supported endpoints:

getMyNews(callback) - returns your activity feed (likes, comments, relationship changes). divided up as new_stories and old_stories.

followingNews(callback) - returns news about your friends activity(likes, comments, relationship changes).

timeline(callback) - like the above but for your own media.

myLikes(callback) - returns all photos you've liked.

directMessages(callback) - returns your entire direct message history.

discover(callback) - what used to be called the "explore" page on the app - returns a stream of photos suggested by Instagram based on your previous activity

searchByUsername(username, callback) - search for a user by username.

getFollowers(userID, callback) - returns a list of everyone a given user is followed by

getFollowings(userID, callback) - returns a list of everyone a given user follows

relationship(userID, callback) - returns your relationship to another user

userInfo(userID, callback) - returns basic profile info about a user

relatedUsers(userID, callback) - like a targeted version of discover, for users. supply a user and get back the other users Instagram has associated with them.

photoStream(userID, callback) - returns a given user's photo stream.

geoData(userID, callback) - returns coordinates for all of a given user's photos.

taggedPhotos(userID, callback) - returns all tagged photos of a given user.

searchFollowings(userID, query, callback) - returns all of a target user's followings that match a given query.

searchFollowers(userID, query, callback) - returns all of a target user's followers that match a given query.

This is an untested proof of concept only. Actually using this would be a violation of Instagram's terms of service and could get your account suspended. Be chill.