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

@tabsircg/fb-sdk

v1.2.2

Published

A strongly-typed, modern TypeScript SDK for the Facebook Graph API (v25.0). It provides a fluent, resource-based interface with automatic `camelCase` ↔ `snake_case` transformation, seamless request batching, and an advanced type-safe field selector system

Readme

@tabsircg/fb-sdk

A strongly-typed, modern TypeScript SDK for the Facebook Graph API (v25.0). It provides a fluent, resource-based interface with automatic camelCasesnake_case transformation, seamless request batching, and an advanced type-safe field selector system that mimics GraphQL.

Tech Stack

  • TypeScript (v5.9.3) - Core language and advanced type system
  • Axios (v1.13.6) - HTTP client for interacting with the Graph API
  • form-data (v4.0.5) - For handling multipart/form-data (used in batching and media uploads)
  • dotenv (v17.3.1) - Environment variable management
  • tsx (v4.21.0) - For rapid development and execution of TypeScript files

Environment Variables

No required environment variables are hardcoded into the SDK itself. However, to interact with the Facebook Graph API, you must supply a valid Access Token when initializing the client wrapper.

For development (npm run dev), you likely need to configure your .env file with a token to test against src/temp/test.ts (though dotenv usage is up to the consumer).

Scripts

| Command | Description | | :--- | :--- | | npm run build | Compiles the TypeScript source code to JavaScript ES2022 format inside the dist/ directory. | | npm run dev | Runs the scratchpad/test file located at src/temp/test.ts using tsx. Useful for local testing. | | npm run prepublishOnly | Automatically runs npm run build prior to publishing the package to npm. |

Quick Start

import { createFbSdk } from '@tabsircg/fb-sdk';

// 1. Initialize the SDK factory (optionally pass configuration like a Store)
const sdkFactory = createFbSdk();

// 2. Instantiate the client with a Page or User Access Token
const sdk = sdkFactory("EAAGYourAccessTokenHere...");

async function run() {
  // Fetch a page's recent posts, selecting specific fields
  const posts = await sdk.page("PAGE_ID").posts.list({
    fields: {
      id: true,
      message: true,
      createdTime: true
    },
    options: {
      limit: 5
    }
  });

  console.log("Recent posts:", posts.data);

  // Example: Publish a new image
  const publishTarget = await sdk.page("PAGE_ID").images.publish({
    url: "https://example.com/image.png",
    message: "Hello world!"
  });
  
  console.log("Published Post ID:", publishTarget.postId);
}

run().catch(console.error);

Common Errors & Fixes

FacebookUploadError

  • Symptom: The SDK throws an error during a video or reel upload, typically containing a FacebookMedia["status"] payload.
  • Fix: This is an asynchronous processing error on Facebook's side. The SDK polls the status of uploads. Inspect the error message (extracted via getProcessingError in poller.ts) which might indicate unsupported codecs, file size limits exceeded, or temporary Facebook outages.

Batching Issues ("API Error code 2/3")

  • Symptom: sdk.batch([ ...requests ]) fails with a confusing Graph API error.
  • Fix: Ensure all requests inside the batch call were invoked without await. A BatchableRequest triggers a standard HTTP call if awaited, but returns { method, relative_url } otherwise which the batch method leverages.

Type errors on fields selector

  • Symptom: TypeScript complains when selecting nested fields like comments: { ... }.
  • Fix: Verify that the nested property is defined as an object or CollectionOf<T> in the type definitions (src/types/). Ensure you use the exact camelCase keys for fields (e.g., createdTime instead of created_time).