From 4de393f25f6b975cd6179b39ba56a9fa1f9562cd Mon Sep 17 00:00:00 2001 From: "Zane J. Chua" Date: Mon, 17 Aug 2020 07:20:08 +0000 Subject: [PATCH] Add Highlights Support --- lib/index.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/index.js b/lib/index.js index 9060571..760797b 100644 --- a/lib/index.js +++ b/lib/index.js @@ -257,6 +257,50 @@ class Instagram { }) } + async getHighlightReels({ + highlightReelIds = [], + reelIds = [], + locationIds = [], + precomposedOverlay = false + } = {}) { + return this.request('/graphql/query/', { + qs: { + query_hash: '45246d3fe16ccc6577e0bd297a5db1ab', + variables: JSON.stringify({ + highlight_reel_ids: highlightReelIds, + reel_ids: reelIds, + location_ids: locationIds, + precomposed_overlay: precomposedOverlay + }) + } + }).then(data => data.data.reels_media) + } + + async getHighlightsByUsername({ username }) { + const user = await this.getUserByUsername({ username }) + return this.request('/graphql/query/', { + qs: { + query_hash: '7c16654f22c819fb63d1183034a5162f', + variables: JSON.stringify({ + user_id: user.id, + include_chaining: true, + include_reel: true, + include_suggested_users: false, + include_logged_out_extras: false, + include_highlight_reels: true + }) + } + }) + .then(data => data.data.user.edge_chaining) + .then(({ edges }) => edges.map(edge => edge.node)) + } + + async getHighlightItemsByReel({ highlightReelId }) { + const reels = await this.getHighlightReels({ highlightReelIds: [highlightReelId] }) + if (reels.length === 0) return [] + return reels[0].items + } + async _getFollowData({ fieldName, queryHash, variables }) { return this.request('/graphql/query/', { qs: {