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

facebook-business-sdk-unofficial

v0.1.0

Published

Unofficial Facebook Business Suite SDK for posting, uploading photos, and managing pages

Downloads

16

Readme

Facebook Business SDK (Unofficial)

Unofficial SDK for Facebook Business Suite. Post content, upload photos, and manage pages programmatically.

Warning: This is an unofficial SDK that uses Facebook's internal APIs. Use at your own risk. These APIs may change without notice.

Installation

npm install facebook-business-sdk-unofficial
# or
bun add facebook-business-sdk-unofficial

Setup

Easy Setup (Recommended)

Just provide your cookies - the SDK will automatically extract the required tokens:

import { FacebookBusiness } from "facebook-business-sdk-unofficial";

// Just need cookies from your browser
const client = await FacebookBusiness.fromCookies("your_cookies_here");

To get cookies:

  1. Login to business.facebook.com
  2. Open DevTools (F12) → Network tab
  3. Find any request and copy the Cookie header value

Manual Setup

If auto-extraction doesn't work, you can provide tokens manually:

const client = new FacebookBusiness({
  cookies: "your_cookies_here",
  fbDtsg: "your_fb_dtsg_token",
  lsd: "your_lsd_token",
});

Usage

Get Pages/Scopes

const { scopes } = await client.getScopes("YOUR_PAGE_ID");

for (const scope of scopes) {
  console.log(`${scope.type}: ${scope.name} (${scope.id})`);
}

Create a Text Post

const { posts } = await client.createPost({
  pageId: "YOUR_PAGE_ID",
  message: "Hello from the SDK!",
});

console.log(`Created: ${posts[0].postId}`);

Post with Photos

// Upload photo first
const photo = await client.uploadPhoto({
  pageId: "YOUR_PAGE_ID",
  file: imageFile, // File or Blob
});

// Create post with the photo
await client.createPost({
  pageId: "YOUR_PAGE_ID",
  message: "Check out this photo!",
  photos: [photo],
});

Post with Multiple Photos

const photo1 = await client.uploadPhoto({ pageId, file: file1 });
const photo2 = await client.uploadPhoto({ pageId, file: file2 });

await client.createPost({
  pageId,
  message: "Multiple photos!",
  photos: [photo1, photo2],
});

Post with Link Preview

await client.createPost({
  pageId: "YOUR_PAGE_ID",
  message: "Check out this article!",
  link: {
    url: "https://example.com/article",
    title: "Article Title",
    summary: "Article description...",
    image: "https://example.com/og-image.jpg",
    imageWidth: 1200,
    imageHeight: 630,
    scrapeId: "...",      // From Facebook's URL scraper
    globalShareId: "...", // From Facebook's URL scraper
    hmac: "...",          // From Facebook's URL scraper
  },
});

API Reference

FacebookBusiness

Constructor

new FacebookBusiness(config: ClientConfig)

| Property | Type | Description | |----------|------|-------------| | cookies | string | Full cookie string from browser | | fbDtsg | string | CSRF token from request body | | lsd | string | LSD token from request body |

Methods

getScopes(assetId: string): Promise<ScopesResult>

Get all pages and assets you have access to.

createPost(options: CreatePostOptions): Promise<CreatePostResult>

Create a post on a Facebook page.

| Option | Type | Description | |--------|------|-------------| | pageId | string | The page ID to post to | | message | string | Post text content | | photos? | UploadedPhoto[] | Photos to attach | | link? | ScrapedLink | Link preview data | | channels? | PostChannel[] | Where to post (default: ["FACEBOOK_NEWS_FEED"]) |

uploadPhoto(options: UploadPhotoOptions): Promise<UploadedPhoto>

Upload a photo for use in posts.

| Option | Type | Description | |--------|------|-------------| | pageId | string | The page ID | | file | File \| Blob | The image file |

License

MIT