api-sadteam / lib /instagram.js
Khrisna's picture
Update lib/instagram.js
30e276c
raw
history blame
4.9 kB
const { iwaTag, iwa, iwaId, iwaIdUrl } = require('instagram-without-api-node');
const _cookie = process.env.COOKIE // <!-- required!! please get your cookie from your browser console (6)
const _userAgent = process.env.USER_AGENT // <!-- required!! please get your user-agent from your browser console (7)
const _xIgAppId = process.env.APPID // <!-- required!! please get your x-ig-app-id from your browser console (8)
// get the latest 12 feeds from a tag (example https://instagram.com/explore/tags/love)
async function insta_iwaTag(tag) {
const responseIwaTag = await iwaTag({
group: 'recent', // <!-- "recent" images or "top" images; "recent" is by default
base64images: true, // <!-- optional, but without you will be not able to save images.. it increases the size of the json file
base64imagesCarousel: false, // <!-- optional but not recommended, it increases the size of the json file
base64videos: false, // <!-- optional but not recommended, it increases the size of the json file
headers: {
'cookie': _cookie,
'user-agent': _userAgent,
'x-ig-app-id': _xIgAppId
},
maxImages: 2, // <!-- optional, 12 is the max number
file: "instagram-cache-bytag.json", // <!-- optional, instagram-cache.json is by default
pretty: true, // <!-- optional, prettyfy json true/false
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
id: tag // <!-- id is required
})
return responseIwaTag
}
// get the latest 12 feeds from an account (example https://www.instagram.com/orsifrancesco/)
async function insta_iwa(username) {
const responseIwa = await iwa({
base64images: true, // <!-- optional, but without you will be not able to save images.. it increases the size of the json file
base64imagesCarousel: false, // <!-- optional but not recommended, it increases the size of the json file
base64videos: false, // <!-- optional but not recommended, it increases the size of the json file
headers: {
'cookie': _cookie,
'user-agent': _userAgent,
'x-ig-app-id': _xIgAppId
},
maxImages: 2, // <!-- optional, 12 is the max number
file: "../tmp/instagram-cache.json", // <!-- optional, instagram-cache.json is by default
pretty: true, // <!-- optional, prettyfy json true/false
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
id: username // <!-- id is required
})
return responseIwa
}
// get picture and info from instagram id url (example https://www.instagram.com/p/Cgczi6qMuh1/)
async function insta_iwaIdUrl(id) {
const responseIwaIdUrl = await iwaIdUrl({
headers: {
'cookie': _cookie,
'user-agent': _userAgent,
'x-ig-app-id': _xIgAppId
},
base64images: false, // <!-- optional, but without it, you will be not able to store/show images
file: "instagram-cache-byidurl.json", // <!-- optional, instagram-cache.json is by default
pretty: true, // <!-- optional, prettyfy json true/false
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
id: id // <!-- id is required
})
return responseIwaIdUrl
}
// get picture and info from instagram id (2890411760684296309 is the id of https://www.instagram.com/p/Cgczi6qMuh1/)
async function insta_iwaId(id) {
const responseIwaId = await iwaId({
base64images: true, // <!-- optional, but without you will be not able to save images.. it increases the size of the json file
base64videos: false, // <!-- optional but not recommended, it increases the size of the json file
headers: {
'cookie': _cookie,
'user-agent': _userAgent,
'x-ig-app-id': _xIgAppId
},
file: "instagram-cache-byid.json", // <!-- optional, instagram-cache.json is by default
pretty: true, // <!-- optional, prettyfy json true/false
time: 3600, // <!-- optional, reload contents after 3600 seconds by default
id: id // <!-- id is required
})
return responseIwaId
}
module.exports = { insta_iwaId, insta_iwaIdUrl, insta_iwa, insta_iwaTag }