instagram-private-api is the npm package most Node.js projects used to read Instagram: about nineteen thousand downloads a week still. It works by signing in as a real Instagram account and calling the endpoints of Instagram's mobile app. Its last free release, 1.46.1, is from March 2024, newer versions are private and paid, and when someone asked in issue #1843 whether it was still active, the answer was "Yes dead api".
This guide reads the same data with SocialTap in Node.js: profiles, posts and reels, comments and hashtags, with no Instagram account.
Why it breaks
The library speaks the private protocol of Instagram's Android app. Every app update can change it, and every request goes out under your account, so heavy reading gets the account challenged or blocked. A typical script starts by signing in:
import { IgApiClient } from "instagram-private-api";
const ig = new IgApiClient();
ig.state.generateDevice(process.env.IG_USERNAME);
await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
const id = await ig.user.getIdByUsername("nasa");
const posts = await ig.feed.user(id).items();That login is the weak point: a checkpoint, a two-factor prompt or a "suspicious login" notice stops the script, and the account it uses is at risk.
The same data with one API key
SocialTap reads what Instagram shows a logged-out visitor, through its own proxies, and returns live data in one schema. Install the SDK (ES modules, Node 20.3 or later):
npm install socialtapGet a key on the signup page and set it as SOCIALTAP_API_KEY. Every account starts with 100 free credits. This reads one profile:
// Save this as app.mjs (an ES module) and run: node app.mjs
import { SocialTap } from "socialtap";
const client = new SocialTap(); // apiKey defaults to process.env.SOCIALTAP_API_KEY
const res = await client.instagram.profile.get({ handle: "https://www.instagram.com/natgeo/" });
console.log(res.data);
console.log(res.credits.charged, res.meta.request_id);ig.user.getIdByUsername and the user info call become one request. The answer has the follower, following and post counts, the bio, links, verification and profile picture.
Walk an account's posts
ig.feed.user(id).items() becomes client.instagram.posts.iterate(), an async iterator that fetches page after page, 12 posts a page, until the list ends or a guard stops it:
// Save this as app.mjs (an ES module) and run: node app.mjs
import { SocialTap, APIError, NotFoundError, PrivateOrUnavailableError } from "socialtap";
const client = new SocialTap(); // apiKey defaults to process.env.SOCIALTAP_API_KEY
try {
// Stops at the end of the list, or at the first guard it reaches.
const items = client.instagram.posts.iterate({ handle: "nasa" }, { maxPages: 10, maxCredits: 100 });
for await (const item of items) {
console.log(item);
}
console.log(items.pagesFetched, items.creditsCharged, items.stopReason, items.endReason);
} catch (err) {
if (err instanceof NotFoundError) {
// The item does not exist or was deleted.
console.error(err.code, err.remediation);
} else if (err instanceof PrivateOrUnavailableError) {
// The item exists but isn't public: it is private, age- or region-restricted, or needs a login.
console.error(err.code, err.remediation);
} else if (err instanceof APIError) {
// Retryable errors reach you only after the SDK's own retries. Failed requests cost no credits.
console.error(err.code, err.status, err.retryable, err.remediation, err.requestId);
} else throw err;
}Each post has its caption, hashtags, mentions, publish time, media and its like, comment and view counts, in the same fields as a TikTok or YouTube post.
From instagram-private-api to SocialTap
| instagram-private-api | SocialTap | Endpoint |
|---|---|---|
ig.user.searchExact(name) | client.instagram.profile.get() | Instagram Profile API |
ig.feed.user(id).items() | client.instagram.posts.iterate() | Instagram Posts API |
ig.media.info(id) | client.instagram.post.get() | Instagram Post API |
ig.feed.mediaComments(id).items() | client.instagram.comments.iterate() | Instagram Comments API |
ig.feed.tags(tag).items() | client.instagram.hashtagPosts.iterate() | Instagram Hashtag Posts API |
The SDK has no runtime dependencies (it uses fetch), and it runs in Node, Deno, Bun and Cloudflare Workers.
What it costs
You pay per successful request, and a list request returns a page:
- Posts of an account: $0.06–$0.17 per 1,000 posts.
- Comments: $0.03–$0.08 per 1,000 comments.
- Profiles: $0.75–$1.97 per 1,000 profiles.
Failed requests and cache hits cost nothing. See plans and packs.
Frequently asked questions
Is instagram-private-api still maintained?
Not the free version. Its last npm release, 1.46.1, is from March 2024, and later versions are sold privately. Instagram has changed its app many times since.
Do I need an Instagram account?
No. SocialTap reads Instagram logged out. You send a username or a link with your SocialTap API key, and no Instagram account is involved, so none can be banned.
Can I read private accounts?
No. A private account returns its public profile, with is_private true, but its posts aren't public. A scraper that signs in can read only the private accounts its own account follows.
Does it work from a server or a serverless function?
Yes. It's an HTTPS request with your key, so it runs from any server, a Lambda or a Cloudflare Worker. The Instagram rate limits that hit cloud IPs are ours to handle.