https://github.com/yatsenkolesh/instagram-nodejs
Simple library for auth, get followers, search by hashtags and locations, like posts, follow, get user feed of instagram with nodejs
https://github.com/yatsenkolesh/instagram-nodejs
instagram instagram-bot instagram-client instagram-feed instagram-nodejs instagram-sdk instagram-search instagram-without-api mass-follow mass-liking nodejs
Last synced: 4 months ago
JSON representation
Simple library for auth, get followers, search by hashtags and locations, like posts, follow, get user feed of instagram with nodejs
- Host: GitHub
- URL: https://github.com/yatsenkolesh/instagram-nodejs
- Owner: yatsenkolesh
- License: mit
- Created: 2017-03-18T03:03:42.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T13:15:57.000Z (over 3 years ago)
- Last Synced: 2025-08-17T00:39:43.810Z (10 months ago)
- Topics: instagram, instagram-bot, instagram-client, instagram-feed, instagram-nodejs, instagram-sdk, instagram-search, instagram-without-api, mass-follow, mass-liking, nodejs
- Language: JavaScript
- Homepage:
- Size: 391 KB
- Stars: 319
- Watchers: 19
- Forks: 74
- Open Issues: 34
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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:
```js
let Instagram = require('instagram-nodejs-without-api');
Instagram = new Instagram()
Instagram.getCsrfToken().then((csrf) =>
{
Instagram.csrfToken = csrf;
}).then(() =>
{
return Instagram.auth('inst-your-username', 'inst-your-password').then(sessionId =>
{
Instagram.sessionId = sessionId
return Instagram.getUserDataByUsername('username-for-get').then((t) =>
{
return Instagram.getUserFollowers(t.graphql.user.id).then((t) =>
{
console.log(t); // - instagram followers for user "username-for-get"
})
})
})
}).catch(console.error);
```
### Follow/unfollow
```js
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
````js
//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
````js
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
````js
//... 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
````js
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
### Tests
You must define a .env file with username and password of the instagram login. (see .env.example)
``` npm test ```
``` yarn test ```