Skip to content

Commit

Permalink
Merge pull request #122 from jlobos/PR_69
Browse files Browse the repository at this point in the history
Add getChainsData method
  • Loading branch information
revall authored May 19, 2020
2 parents 9b6f300 + 8043d8b commit 200a442
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const client = new Instagram({ username, password, cookieStore })
* [.getPhotosByHashtag({hashtag, first, after})](#gethastagphotosparams)
* [.getPhotosByUsername({username, first, after})](#getphotosbyusernameparams)
* [.getPrivateProfilesFollowRequests(cursor)](#getPrivateProfilesFollowRequests)
* [.getChainsData({ userId })](#getChainsData)

### Instagram(credentials, opts)
```js
Expand Down Expand Up @@ -462,6 +463,14 @@ await client.getPhotosByHashtag({ hashtag: 'unicorn' })
await client.getPrivateProfilesFollowRequests(cursor)
```

### getChainsData
```js
await client.getChainsData({ userId })
```
> This will return the similar accounts, that you see, when you click on the ARROW in a profile.
- `params`
- `userId`: The user id

## License

MIT © [Jesús Lobos](https://jlobos.com/)
18 changes: 18 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,24 @@ class Instagram {
})
}

async getChainsData({ userId }) {
return this.request('/graphql/query/', {
qs: {
query_hash: '7c16654f22c819fb63d1183034a5162f',
variables: JSON.stringify({
user_id: userId,
include_chaining: true,
include_reel: false,
include_suggested_users: false,
include_logged_out_extras: false,
include_highlight_reels:false
})
}
})
.then(data => data.data.user.edge_chaining)
.then(({ edges }) => edges.map(edge => edge.node));
}

async getActivity() {
return this.request('/accounts/activity/?__a=1').then(
data => data.graphql.user
Expand Down
5 changes: 5 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,8 @@ test('getPrivateProfilesFollowRequests', async t => {
const { page_name } = await client.getPrivateProfilesFollowRequests()
t.is(page_name, 'current_follow_requests')
})

test('getChainsData', async t => {
const response = await client.getChainsData({ userId: users.Maluma.id })
t.true(Array.isArray(response))
})

0 comments on commit 200a442

Please sign in to comment.