Giter Site home page Giter Site logo

leovicio / instagram-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yatsenkolesh/instagram-nodejs

0.0 1.0 0.0 37 KB

Simple library for auth, get followers, search on hashtags and locations, like posts, follow, get user feed on instagram with nodejs

JavaScript 100.00%

instagram-nodejs's Introduction

instagram-nodejs

Auth and get followers on instagram with nodejs

Join us with gitter: https://gitter.im/nodejs-instagram/Library

Important : you must update csrf token and sessionId only if password was changed

To install from npm repository (I recommended use yarn, but you can use npm):

yarn add instagram-nodejs-without-api

You can get instagram followers with next code:

Instagram = new Instagram()


Instagram.getCsrfToken().then((csrf) =>
{
  Instagram.csrfToken = csrf;
}).then(() =>
{
  Instagram.auth('inst-your-username', 'inst-your-password').then(sessionId =>
  {
    Instagram.sessionId = sessionId

    Instagram.getUserDataByUsername('username-for-get').then((t) =>
    {
      Instagram.getUserFollowers(JSON.parse(t).user.id).then((t) =>
      {
        console.log(t); // - instagram followers for user "username-for-get"
      })
    })

  })
})

Follow/unfollow

Inst = new Instagram()

Inst.csrfToken = 'your-csrf'
Inst.sessionId = 'your-session-id'
Inst.follow(3,0) //follow "kevin"
Inst.follow(3, 1) //unfollow "kevin"

Like/unlike

  //get media id by url and like
  Insta.getMediaIdByUrl('https://www.instagram.com/p/BT1ynUvhvaR/').then(r => Insta.like(r).then(d => console.log(d)))
  //get media id by url and unlike
  Insta.getMediaIdByUrl('https://www.instagram.com/p/BT1ynUvhvaR/').then(r => Insta.unlike(r).then(d => console.log(d)))

Get feed

  let pageFirst = Insta.getFeed(10).then(function(t)
  {
    let PageSecond = Insta.getFeed(10, Insta.getFeedNextPage(t)).then(function(t)
    {
      //two page
      console.log(t)
    })
  })

Get user media

  //... auth (look up)
  //for example: get 12 first media entries for "kevin"
  // 0 - if you need to get first page
  // next cursor : r.page_info.end_cursor
  Insta.getUserMedia(3, '0', 12).then(f => console.log(f))

Get media by hashtags and locations

  Insta.commonSearch('Kyiv').then(r =>
  {
    //get location id for Kyiv
    let locationId = r.places[0].place.location['pk']
    //search posts from Kyiv
    Insta.searchBy('location', locationId, '0', 12).then(r => console.log(r))
  })
  //search posts by hashtag "Eurovision"
  Insta.searchBy('hashtag', 'Eurovision').then(r => console.log(r))

When you pass items counter param instagram create pagination tokens on all iterations and gives on every response end_cursor, which the need to pass on next feed request

You can get user id with Inst.getUserDataByUsername() method

Star this repository on github, please. Thank you

instagram-nodejs's People

Contributors

yatsenkolesh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.