Skip to content

Commit 4de393f

Browse files
committed
Add Highlights Support
1 parent e85a0f6 commit 4de393f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

lib/index.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,50 @@ class Instagram {
257257
})
258258
}
259259

260+
async getHighlightReels({
261+
highlightReelIds = [],
262+
reelIds = [],
263+
locationIds = [],
264+
precomposedOverlay = false
265+
} = {}) {
266+
return this.request('/graphql/query/', {
267+
qs: {
268+
query_hash: '45246d3fe16ccc6577e0bd297a5db1ab',
269+
variables: JSON.stringify({
270+
highlight_reel_ids: highlightReelIds,
271+
reel_ids: reelIds,
272+
location_ids: locationIds,
273+
precomposed_overlay: precomposedOverlay
274+
})
275+
}
276+
}).then(data => data.data.reels_media)
277+
}
278+
279+
async getHighlightsByUsername({ username }) {
280+
const user = await this.getUserByUsername({ username })
281+
return this.request('/graphql/query/', {
282+
qs: {
283+
query_hash: '7c16654f22c819fb63d1183034a5162f',
284+
variables: JSON.stringify({
285+
user_id: user.id,
286+
include_chaining: true,
287+
include_reel: true,
288+
include_suggested_users: false,
289+
include_logged_out_extras: false,
290+
include_highlight_reels: true
291+
})
292+
}
293+
})
294+
.then(data => data.data.user.edge_chaining)
295+
.then(({ edges }) => edges.map(edge => edge.node))
296+
}
297+
298+
async getHighlightItemsByReel({ highlightReelId }) {
299+
const reels = await this.getHighlightReels({ highlightReelIds: [highlightReelId] })
300+
if (reels.length === 0) return []
301+
return reels[0].items
302+
}
303+
260304
async _getFollowData({ fieldName, queryHash, variables }) {
261305
return this.request('/graphql/query/', {
262306
qs: {

0 commit comments

Comments
 (0)