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

@santhosh785/meta-ads

v1.0.0

Published

Reusable, fetch-only connector for the Meta (Facebook) Marketing API. Returns normalized data; no database, no business logic.

Readme

@santhosh785/meta-ads

A reusable, fetch-only connector for the Meta (Facebook) Marketing API.

It authenticates, calls the Graph API, handles pagination and retries, and returns normalized data. That's it.

It does not: touch a database, use Prisma, know about tenants, read environment variables, or contain any business/CRM logic. The caller owns all of that.

Install

npm install @santhosh785/meta-ads

Requires Node.js 18+ (uses the built-in global fetch; zero runtime dependencies).

Usage

import { MetaAdsConnector } from "@santhosh785/meta-ads";

const meta = new MetaAdsConnector({
  accessToken,
  adAccountId,          // with or without the "act_" prefix
  apiVersion: "v24.0",  // optional
});

await meta.validateToken();
await meta.getCampaigns();
await meta.getAdsets();               // or { campaignId }
await meta.getAds();                  // or { campaignId } / { adsetId }
await meta.getCreatives();
await meta.getInsights({ from: "2026-07-01", to: "2026-07-03", level: "campaign" });
await meta.getLeads(formId);
await meta.getLeadForms(pageId);

Configuration

| Option | Required | Default | Description | | ------------- | -------- | ------------------------------ | ---------------------------------- | | accessToken | yes | — | Meta access token | | adAccountId | yes | — | Ad account id (act_ auto-added) | | apiVersion | no | v24.0 | Graph API version | | baseUrl | no | https://graph.facebook.com | Override for testing | | maxRetries | no | 3 | Retry attempts for transient fails | | timeoutMs | no | 30000 | Per-request timeout |

Pagination

Every list method automatically follows paging.next and returns the full set. Callers never handle Meta pagination manually.

Retry strategy

Automatically retried with exponential backoff + jitter:

  • HTTP 429 (rate limiting)
  • Transient 5xx server errors
  • Network errors / timeouts

Never retried (fail fast):

  • Invalid/expired token → MetaAuthError
  • Missing permission → MetaPermissionError
  • Invalid request → MetaValidationError

All errors extend MetaError and expose httpStatus, code, subcode, type, fbtraceId, and retryable.

Using it in a backend

The package only fetches — persistence is the caller's job:

const campaigns = await meta.getCampaigns();
for (const campaign of campaigns) {
  await prisma.metaCampaign.upsert(/* ... */);
}

Build

npm run build      # emits dist/ (ESM + .d.ts)
npm run typecheck  # type-check only

Philosophy

Fetch only. Communicate with Meta, return clean data. Everything else belongs in the application using the package.