https://github.com/killerwolf/instagram-data-extractor
https://github.com/killerwolf/instagram-data-extractor
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/killerwolf/instagram-data-extractor
- Owner: killerwolf
- Created: 2025-05-28T15:12:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-05T12:55:42.000Z (about 1 year ago)
- Last Synced: 2025-07-11T14:00:53.855Z (11 months ago)
- Language: TypeScript
- Size: 48.8 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Instagram Data Extractor
A TypeScript library for extracting post data from Instagram, including descriptions, author information, and media (images/videos).
## Installation
```bash
npm install @h4md1/instagram-data-extractor
# or
yarn add @h4md1/instagram-data-extractor
```
## Usage
```typescript
import { InstagramExtractor } from '@h4md1/instagram-data-extractor';
async function getPostData() {
try {
const postData = await InstagramExtractor.extractPost('shortcode');
console.log('Post description:', postData.description);
console.log('Author:', postData.author.username);
console.log('Media URL:', postData.media.url);
} catch (error) {
console.error('Failed to extract post:', error);
}
}
```
## API
### InstagramExtractor.extractPost(shortcode: string, config?: RequestConfigType)
Extracts data from an Instagram post.
#### Parameters
- `shortcode`: The Instagram post shortcode (found in the post URL)
- `config`: Optional request configuration (extends RequestInit)
#### Returns
Returns a Promise that resolves to an InstagramPostData object:
## Error Handling
The library throws errors in the following cases:
- Network errors during the API request
- Invalid or missing shortcode
- Post not found
- API rate limiting
Make sure to wrap the `extractPost` call in a try-catch block to handle potential errors.
## License
MIT
## CLI Usage
You can extract Instagram post data directly from the command line:
### Using npx
```sh
npx @h4md1/instagram-data-extractor@latest extract
```
### Using node
```sh
node dist/cli.js extract
```
Replace `` with the Instagram post shortcode (e.g., `DJ_1LHjIUKb`).
## Credits
This package is heavily inspired by [riad-azz/instagram-video-downloader](https://github.com/riad-azz/instagram-video-downloader).