Ampost Node.js SDK

By Published Updated

ampost on npm is the official TypeScript and JavaScript client for the Ampost API: one call publishes, schedules or drafts a post on every network you connect, and every request and response is typed.

Install

Node 18 or later. The package has no runtime dependencies and ships ESM and CommonJS.

terminal
npm install ampost

Publish a post

Create an API key in Settings, API keys, connect Bluesky and Threads in the dashboard, and put the key in AMPOST_API_KEY. Then:

post.mjs
import { Ampost } from "ampost";

const ampost = new Ampost({ apiKey: process.env.AMPOST_API_KEY });

const post = await ampost.posts.create({
  text: "Hello from the Ampost API 👋",
  targets: [{ platforms: ["bluesky", "threads"] }],
  publishNow: true,
});
console.log(post.id, post.status, post.platformPosts.map((p) => `${p.platform}: ${p.status}`));

What it does

  • Typed requests and responses for every endpoint, generated from the OpenAPI document.
  • Retries on 429 and 5xx with Retry-After, an automatic Idempotency-Key per call, and typed errors (BadRequestError, RateLimitError, ...).
  • for await pagination and a one-call media upload (ampost.media.upload).
  • CommonJS works the same: const { Ampost } = require("ampost").

Schedule or save a draft

Leave out publishNow for a draft, or set scheduledFor to an ISO 8601 time to schedule the post (paid plans). Every field is the same as in the REST API reference.