UNPKG

instagram-api.js

Version:

A easy to use instagram public api wrapper

28 lines (27 loc) 859 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.user = void 0; const fetch_1 = require("@sapphire/fetch"); /** * @example * const { user } = require("instagram-api.js"); * (() => { * const userInfo = await user("mrbeast"); * console.log(userInfo); * })(); * Note: This search instagram user public api info */ async function user(userName, sessionId) { if (!userName) return null; try { const apiResult = await (0, fetch_1.fetch)(`https://instagram.com/${userName}${sessionId ? "" : "/feed"}/?__a=1`, { headers: sessionId ? { cookie: `sessionid=${sessionId}` } : {} }, "json" /* JSON */); if (!apiResult.graphql) return null; return apiResult.graphql.user; } catch (e) { return null; } } exports.user = user;