instagram-stories
Advanced tools
Comparing version 1.0.1 to 1.1.0
67
index.js
const fetch = require('isomorphic-fetch') | ||
exports.getUserByUsername = username => ( | ||
fetch(`https://www.instagram.com/${username}/?__a=1`) | ||
.then(res => res.json()) | ||
const defaultHeaders = { | ||
'sec-ch-ua': '"Google Chrome";v="87", " Not;A Brand";v="99", "Chromium";v="87"', | ||
'sec-ch-ua-mobile': '?0', | ||
'sec-fetch-dest': 'empty', | ||
'sec-fetch-mode': 'cors', | ||
'sec-fetch-site': 'same-site', | ||
'x-ig-app-id': '936619743392459', | ||
'x-ig-www-claim': 'hmac.AR0A6WzcCoXWstKAUuy1gRbCQFUs8FoZCp3ap2UMk_KQNBSH' | ||
} | ||
const getHeaders = (headers, sessionid, userid) => { | ||
return Object.assign(headers, { | ||
cookie: `sessionid=${sessionid}; ds_user_id=${userid}` | ||
}) | ||
} | ||
exports.getUserByUsername = ({ | ||
username, | ||
sessionid, | ||
userid, | ||
headers = defaultHeaders | ||
}) => ( | ||
fetch(`https://www.instagram.com/${username}/?__a=1`, { | ||
headers: getHeaders(headers, sessionid, userid) | ||
}) | ||
.then(res => res.json()) | ||
.then(({graphql}) => graphql) | ||
) | ||
exports.getMediaByCode = code => ( | ||
fetch(`https://www.instagram.com/p/${code}/?__a=1`) | ||
.then(res => res.json()) | ||
exports.getMediaByCode = ({ | ||
code, | ||
sessionid, | ||
userid, | ||
headers = defaultHeaders | ||
}) => ( | ||
fetch(`https://www.instagram.com/p/${code}/?__a=1`, { | ||
headers: getHeaders(headers, sessionid, userid) | ||
}) | ||
.then(res => res.json()) | ||
) | ||
@@ -17,14 +48,20 @@ | ||
userid, | ||
headers = { | ||
'x-ig-capabilities': '3w==', | ||
'user-agent': 'Instagram 9.5.1 (iPhone9,2; iOS 10_0_2; en_US; en-US; scale=2.61; 1080x1920) AppleWebKit/420+', | ||
host: 'i.instagram.com' | ||
} | ||
headers = defaultHeaders | ||
}) => ( | ||
fetch(`https://i.instagram.com/api/v1/feed/user/${id}/reel_media/`, { | ||
headers: Object.assign(headers, { | ||
cookie: `sessionid=${sessionid}; ds_user_id=${userid}` | ||
}) | ||
fetch(`https://i.instagram.com/api/v1/feed/reels_media/?reel_ids=${id}`, { | ||
headers: getHeaders(headers, sessionid, userid) | ||
}) | ||
.then(res => res.json()) | ||
.then(({status, reels_media: {0: stories}}) => Object.assign({}, {status}, stories || {items: []})) | ||
) | ||
exports.getStoriesFeed = ({ | ||
sessionid, | ||
userid, | ||
headers = defaultHeaders | ||
}) => ( | ||
fetch(`https://i.instagram.com/api/v1/feed/reels_tray/`, { | ||
headers: getHeaders(headers, sessionid, userid) | ||
}) | ||
.then(res => res.json()) | ||
) |
{ | ||
"name": "instagram-stories", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Instagram Stories", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
# instagram-stories | ||
[![Build Status](https://travis-ci.org/jlobos/instagram-stories.svg?branch=master)](https://travis-ci.org/jlobos/instagram-stories) | ||
[![Build Status](https://travis-ci.com/konstantinov/instagram-stories.svg?branch=master)](https://travis-ci.com/github/konstantinov/instagram-stories) | ||
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) | ||
@@ -19,2 +19,3 @@ | ||
getStories, | ||
getStoriesFeed, | ||
getMediaByCode, | ||
@@ -32,7 +33,12 @@ getUserByUsername | ||
getMediaByCode('BUu14BdBkO5').then(media => { | ||
// Get stories of people you follow | ||
getStoriesFeed({ userid: 1284161654, userid: 1284161654, sessionid: '' }).then(feed => { | ||
console.log(feed) | ||
}) | ||
getMediaByCode({ code: 'BUu14BdBkO5', userid: 1284161654, sessionid: '' }).then(media => { | ||
console.log(media) | ||
}) | ||
getUserByUsername('instagram').then(({ user }) => { | ||
getUserByUsername({ username: 'instagram', userid: 1284161654, sessionid: '' }).then(({ user }) => { | ||
console.log(user.id) | ||
@@ -39,0 +45,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4522
60
49
5