A lightweight and framework-agnostic package to fetch Instagram media (reels, posts, videos, etc.) using the Instagram Graph API. Simply provide your account_id and access_token to retrieve all media content from your account effortlessly. Caching is supported to reduce API requests and improve performance.
npm install insta-scoopStore your credentials securely in a .env file:
INSTAGRAM_ACCOUNT_ID=your-instagram-id
INSTAGRAM_ACCESS_TOKEN=your-access-tokenimport { getInstagramMedia } from "insta-scoop";
import dotenv from "dotenv";
dotenv.config();
const accountId = process.env.INSTAGRAM_ACCOUNT_ID;
const accessToken = process.env.INSTAGRAM_ACCESS_TOKEN;
async function getInstagramData() {
try {
const media = await getInstagramMedia({ accountId, accessToken });
console.log(media);
} catch (error) {
console.error("Error fetching Instagram data:", error);
}
}
getInstagramData();- Go to Facebook Developer Platform
- Create a new app and choose Other as the app type
- On the next screen, select Business and proceed
- Once your app is created, navigate to the Dashboard
- Click on Instagram and press Set Up
- Under the Generate Access Tokens section, click Add Account
- Log in to the Instagram account you want to retrieve data from
- After logging in, you will see a numeric account ID below the username. Save this value
- In the Access Token section, click Generate Token
- Log in again to confirm and retrieve the generated token
- Copy and store the access token securely
- Visit: Access Token Debugger
- Enter your token to check if it is valid and active
MIT