# insta-fetcher

> Simplified Instagram metadata scraping

Latest version **1.4.0** (published 2026-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install insta-fetcher
pnpm add insta-fetcher
yarn add insta-fetcher
bun add insta-fetcher
```

## Health

**Score 50/100 (C)** — status: active.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2026-03-23 |
| First published | 2021-03-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 109.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 91 |
| Author | Muhamad Ristiyanto |
| Maintainers | gimenz |
| Keywords | instagram-scraper, instagram-downloader, instagram-saver, insta-scraper, instagram, ig-scraper, ig-api, instagram-private-api, instagram-api, instagram-scraping |

## Links

- npm: https://www.npmjs.com/package/insta-fetcher
- Repository: https://github.com/Gimenz/insta-fetcher
- Issues: https://github.com/Gimenz/insta-fetcher/issues
- npm.io page: https://npm.io/package/insta-fetcher

## Dependencies (3)

- [axios](https://npm.io/package/axios.md) ^1.13.6
- [form-data](https://npm.io/package/form-data.md) ^4.0.0
- [big-integer](https://npm.io/package/big-integer.md) ^1.6.51

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 1.4.0 (latest) — 2026-03-23
- 1.3.35 — 2024-04-12
- 1.3.34 — 2024-03-13
- 1.3.33 — 2024-03-13
- 1.3.32 — 2024-03-02
- 1.3.31 — 2024-03-01
- 1.3.3 — 2024-02-26
- 1.3.27 — 2023-12-02
- 1.3.26 — 2023-07-20
- 1.3.25 — 2022-10-27
- 1.3.24 — 2022-10-14
- 1.3.23 — 2022-07-05
- 1.3.22 — 2022-06-30
- 1.3.21 — 2022-04-28
- 1.3.20 — 2022-04-06
- … 30 more at https://npm.io/package/insta-fetcher/versions

## README

# Insta Fetcher

[![HitCount](http://hits.dwyl.com/Gimenz/insta-fetcher.svg)](http://hits.dwyl.com/Gimenz/insta-fetcher) [![GitHub license](https://img.shields.io/github/license/Gimenz/insta-fetcher)](https://github.com/Gimenz/insta-fetcher/blob/master/LICENSE) [![Npm package monthly downloads](https://badgen.net/npm/dm/insta-fetcher)](https://npmjs.com/package/insta-fetcher) ![GitHub repo size](https://img.shields.io/github/repo-size/Gimenz/insta-fetcher?style=flat) [![npm version](https://badge.fury.io/js/insta-fetcher.svg)](https://badge.fury.io/js/insta-fetcher)

Simple Instagram metadata scraping library for Node.js, written in TypeScript.

📖 **[Full Documentation](https://gimenz.github.io/insta-fetcher/)**  
☕ **[Buy Me a Coffee](https://saweria.co/masgimenz)**

## Installation
 
```bash
npm install insta-fetcher
```

---
 
## Setup
 
Instagram requires a valid session cookie for most requests. Get yours with `getCookie`:
 
```typescript
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
 
```typescript
const ig = new igApi(cookie, {
    proxy: {
        host: 'proxy-url',
        port: 'proxy-port',
        auth: {
            username: 'proxy-user',
            password: 'proxy-password'
        }
    }
});
```
 
---

## Example
 
### Fetch Post
 
```typescript
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
 
```typescript
// 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
 
```typescript
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
 
```typescript
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)
 
```typescript
// 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
 
```typescript
const reels = await ig.fetchUserReel('username');
 
// With pagination
const nextReels = await ig.fetchUserReel('username', 'end_cursor');
```
 
### Fetch Account Info
 
```typescript
// Fetches your own account info based on cookie
const account = await ig.accountInfo();
console.log(account);
```
 
### Search Followers / Following
 
```typescript
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
 
```typescript
// 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
 
```typescript
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](https://github.com/Gimenz/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](./LICENSE)

---
_Source: https://npm.io/package/insta-fetcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
