npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

insta-fetcher

v1.4.0

Published

Simplified Instagram metadata scraping

Downloads

2,299

Readme

Insta Fetcher

HitCount GitHub license Npm package monthly downloads GitHub repo size npm version

Simple Instagram metadata scraping library for Node.js, written in TypeScript.

📖 Full Documentation
Buy Me a Coffee

Installation

npm install insta-fetcher

Setup

Instagram requires a valid session cookie for most requests. Get yours with getCookie:

import { igApi, getCookie } from 'insta-fetcher';
 
// Get session cookie (only need to do this once)
const cookie = await getCookie('your_username', 'your_password');
console.log(cookie);
 
// Initialize with cookie
const ig = new igApi(cookie);

Note: Save your cookie somewhere (e.g. .env) so you don't need to login every time.

With Proxy

const ig = new igApi(cookie, {
    proxy: {
        host: 'proxy-url',
        port: 'proxy-port',
        auth: {
            username: 'proxy-user',
            password: 'proxy-password'
        }
    }
});

Example

Fetch Post

const post = await ig.fetchPost('https://www.instagram.com/p/xxxxx/');
console.log(post);
 
/*
{
  username: 'fiiyya21',
  name: 'Fiya',
  postType: 'image',
  media_id: '2841182589568357263_3026954032',
  shortcode: 'Cdt6IP7Pd2D',
  taken_at_timestamp: 1652915380,
  likes: 3,
  caption: 'some caption here',
  media_count: 2,
  comment_count: 15,
  video_duration: null,
  music: null,
  links: [
    {
      id: '...',
      url: 'https://...',
      type: 'image',
      dimensions: { height: 720, width: 720 }
    }
  ]
}
*/

Fetch User Info

// Simple user info
const user = await ig.fetchUserV2('username');
console.log(user);
 
// Detailed user info (includes email, phone if public)
const userDetail = await ig.fetchUser('username');
console.log(userDetail);
 
// Get user ID from username
const userId = await ig.getIdByUsername('username');
console.log(userId);

Fetch Stories

const stories = await ig.fetchStories('username');
console.log(stories);
 
/*
{
  username: 'username',
  stories_count: 3,
  stories: [
    {
      type: 'image' | 'video',
      url: 'https://...',
      taken_at: 1652915380,
      expiring_at: 1652915380,
      ...
    }
  ]
}
*/

Fetch Highlights

const highlights = await ig.fetchHighlights('username');
console.log(highlights);
 
/*
{
  username: 'username',
  highlights_count: 5,
  data: [
    {
      title: 'Highlight Title',
      cover: 'https://...',
      media_count: 10,
      highlights_id: '...',
      highlights: [ ... ]
    }
  ]
}
*/

Fetch User Posts (Paginated)

// First page
const posts = await ig.fetchUserPostsV2('username');
 
// Next page using next_max_id
const nextPosts = await ig.fetchUserPostsV2('username', 'next_max_id');

Fetch User Reels

const reels = await ig.fetchUserReel('username');
 
// With pagination
const nextReels = await ig.fetchUserReel('username', 'end_cursor');

Fetch Account Info

// Fetches your own account info based on cookie
const account = await ig.accountInfo();
console.log(account);

Search Followers / Following

const userId = await ig.getIdByUsername('username');
 
const followers = await ig.searchFollower(userId, 'search_term');
const following = await ig.searchFollowing(userId, 'search_term');

Post a Photo

// Post to feed
await ig.addPost('./photo.jpg', 'feed', {
    caption: 'Hello from insta-fetcher!'
});
 
// Post to story
await ig.addPost('./photo.jpg', 'story', {});

Change Profile Picture

await ig.changeProfilePicture('./new_photo.jpg');

Contributing

All contributions are welcome — code, bug reports, documentation, or new features.

  1. Fork this repo
  2. Create your branch: git checkout -b feat/your-feature
  3. Commit your changes: git commit -m 'feat: add some feature'
  4. Push to the branch: git push origin feat/your-feature
  5. Open a Pull Request

Related Projects

  • nganu — WhatsApp Bot using this library

References

  • https://github.com/dilame/instagram-private-api
  • https://github.com/ldtsystem2020/Instagram_API
  • https://github.com/jlobos/instagram-web-api

License

MIT