/node-instagram

Instagram API based on promise

Primary LanguageJavaScript

Node Instagram Api

Retrieve media without official instagram api support. (Based on promise)

Install with npm

npm install node-instagram-api

Login

You need to fill CSRFTOKEN and SESSIONID later.

$ node login                                                                                                                                                                               <<<
Username: example
Password: 

If success, you will get

{ status: 'ok',
  authenticated: true,
  user: 'example',
  csrftoken: '<YOUR CSRFTOKEN>',
  sessionid: '<YOUR SESSIONID>' }

API Reference

new Instagram(params)

var nodeInstagram = require('node-instagram');

var ig = new nodeInstagram.Instagram({
  sessionId: '<YOUR SESSIONID HERE>',
  csrftoken: '<YOUR CSRFTOKEN HERE>'
})
Param Type Description
sessionId String your instagram session id
csrftoken String your instagram csrftoken

fetchUserPost(id, numOfPost) => Promise

ig.fetchUserPost('fumeancat', 5).then(function(output) {
  console.log(output.media.nodes)
}).fail(function(err) {
  console.log(err)
}); 

ig.fetchTag(tag, numOfPost, iterations) => Promise

ig.fetchTag('台南', 12, 1).then(function(output) {
  console.log(output)
}).fail(function(err) {
  console.log(err)
});

ig.fetchPost(code) => Promise

ig.fetchPost('BGQ3dhCEK73').then(function(output) {
  console.log(output.media.likes.nodes)
}).fail(function(err) {
  console.log(err)
});

ig.addComment(postId, comment) => Promise

Add a comment to a post.

ig.addComment('1261997285197436496', 'Test').then(function(output) {
  console.log(output)
}).fail(function(err) {
  console.log(err)
});

ig.addLike(postId) => Promise

Send like to a post.

ig.addLike('1262841227841807675').then(function(output) {
  console.log(output)
}).fail(function(err) {
  console.log(err)
});

ig.fetchUserInfo(username) => Promise

ig.fetchUserInfo('fumeancat').then(function(output) {
  console.log(output);
}).fail(function(err) {
  console.log(err);
})

ig.fetchFollower(username, numOfFollower) => Promise

Get follower of a user.

ig.fetchFollower('fumeancat', 999).then(function(output) {
  console.log(output.followed_by.nodes);
}).fail(function(err) {
  console.log(err);
})

ig.fetchFollows(username, numOfFollower) => Promise

Get user follows.

ig.fetchFollows('fumeancat', 999).then(function(output) {
  console.log(output.follows.nodes);
}).fail(function(err) {
  console.log(err);
})