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

oktopost

v1.0.1

Published

Official Node.js SDK for the Oktopost API

Readme

Oktopost Node.js SDK

Official Node.js/TypeScript SDK for the Oktopost API v2.

Installation

npm install oktopost

Requirements

  • Node.js 18 or later
  • An Oktopost account with API access

Quick Start

import { Oktopost } from 'oktopost';

const client = new Oktopost({
  accountId: process.env.OKTOPOST_ACCOUNT_ID!,
  apiKey: process.env.OKTOPOST_API_KEY!,
});

const campaigns = await client.publishing.campaigns.list({ status: 'active' });
console.log(campaigns.Items);

Configuration

const client = new Oktopost({
  accountId: 'your-account-id',
  apiKey: 'your-api-key',
  region: 'us',           // 'us' (default) or 'eu'
  baseUrl: undefined,      // Override base URL for testing
  timeout: 30_000,         // Request timeout in ms (default: 30s)
  maxRetries: 3,           // Max retry attempts (default: 3)
  fetch: customFetch,      // Custom fetch implementation
  onRequest: (info) => {}, // Debug hook: called before each request
  onResponse: (info) => {},// Debug hook: called after each response
});

API Namespaces

The SDK mirrors the Oktopost API documentation structure:

| Namespace | Access | Resources | |-----------|--------|-----------| | Account | client.account | users, teams, teamEntities, socialProfiles, cnames, conversionTags, notifications | | Publishing | client.publishing | campaigns, messages, posts, postLog, media, uploads, calendar, tags, links | | Analytics | client.analytics | postAnalytics, followers, clicks, exports | | Inbox | client.inbox | comments | | Advocacy | client.advocacy | advocates, boards, stories, boardMessages, topics | | Approvals | client.approvals | workflows, workflowSteps, workflowItems, workflowItemNotes | | Streams | client.streams | tabs, streams | | Leads | client.leads | leads, activities, links | | Events | client.events | webhooks, webhookLog | | Integrations | client.integrations | (direct methods on namespace) |

Pagination

Three ways to handle paginated endpoints:

// 1. Manual pagination
const page = await client.publishing.campaigns.list({ _page: 0, _count: 100 });
console.log(page.Items, page.Total);

// 2. AsyncIterator - streams items one by one
for await (const campaign of client.publishing.campaigns.listAll()) {
  console.log(campaign.Id);
}

// 3. Collect all into an array
import { collectAll } from 'oktopost';
const allCampaigns = await collectAll(client.publishing.campaigns.listAll());

Error Handling

import {
  OktopostApiError,
  OktopostAuthError,
  OktopostRateLimitError,
  OktopostNotFoundError,
  OktopostPermissionError,
  OktopostTimeoutError,
} from 'oktopost';

try {
  await client.publishing.campaigns.get('invalid-id');
} catch (err) {
  if (err instanceof OktopostNotFoundError) {
    console.log('Campaign not found');
  } else if (err instanceof OktopostAuthError) {
    console.log('Invalid credentials');
  } else if (err instanceof OktopostRateLimitError) {
    console.log('Rate limited, retry after cooldown');
  } else if (err instanceof OktopostApiError) {
    console.log('API error:', err.message, err.errors);
  }
}

Webhooks

Webhook signature verification uses a separate entry point to keep node:crypto out of the main bundle:

import { verifyWebhookSignature, constructEvent } from 'oktopost/webhooks';

// Verify signature
const isValid = verifyWebhookSignature(rawBody, signature, secret);

// Or verify + parse in one step
const event = constructEvent(rawBody, signature, secret);
console.log(event.event, event.data);

Retry & Rate Limiting

The SDK includes built-in retry logic and proactive rate limiting:

  • Retries: Automatically retries on 429 (rate limit) and 5xx (server errors) with exponential backoff
  • Never retries: 400, 401, 403, 404 (client errors)
  • Rate limiting: Proactively delays requests at 85% of burst limits to prevent the 15-minute lockout

TypeScript

All types are exported from the main package:

import { Oktopost, type Campaign, type Post, type User, type Network } from 'oktopost';

License

MIT