ChirpieDocs
SDK

TypeScript SDK

Use the @chirpie/sdk package for type-safe API access from Node.js and TypeScript.

The official TypeScript SDK provides a type-safe client for the Chirpie API.

Installation

npm install @chirpie/sdk
yarn add @chirpie/sdk
pnpm add @chirpie/sdk

Quick Start

import { ChirpieClient } from "@chirpie/sdk";

const chirpie = new ChirpieClient({
  apiKey: process.env.CHIRPIE_API_KEY!,
});

// Create a post
const post = await chirpie.createPost({
  account_id: "YOUR_ACCOUNT_ID",
  text: "Hello from the SDK!",
});

console.log(post.id, post.status);

Configuration

const chirpie = new ChirpieClient({
  apiKey: "chirpie_sk_YOUR_KEY",
  baseUrl: "https://chirpie.ai",  // Optional, defaults to chirpie.ai
});

Or use environment variables:

export CHIRPIE_API_KEY=chirpie_sk_YOUR_KEY
export CHIRPIE_BASE_URL=https://chirpie.ai  # Optional
import { ChirpieClient, requireConfig } from "@chirpie/sdk";

const config = requireConfig();  // Reads from env or ~/.chirpie/config.json
const chirpie = new ChirpieClient({
  apiKey: config.api_key,
  baseUrl: config.base_url,
});

Methods

Posts

// Create a post
const post = await chirpie.createPost({
  account_id: "uuid",
  text: "Hello world!",
  schedule_at: "2026-04-01T14:00:00Z",  // Optional
});

// List posts
const posts = await chirpie.listPosts({
  status: "published",  // Optional filter
  account_id: "uuid",   // Optional filter
  limit: 20,            // Default 20, max 100
  offset: 0,
});

// Get a single post
const post = await chirpie.getPost("post-uuid");

// Delete a post
const result = await chirpie.deletePost("post-uuid");

Threads

const thread = await chirpie.createThread({
  account_id: "uuid",
  posts: [
    { text: "First post in thread" },
    { text: "Second post in thread" },
    { text: "Third post in thread" },
  ],
  schedule_at: "2026-04-01T14:00:00Z",  // Optional
});

Accounts

// List connected accounts
const accounts = await chirpie.listAccounts();

// Connect an X account (starts OAuth flow)
const { authorization_url } = await chirpie.connectXAccount();

// Connect a Bluesky account (app password)
const blueskyAccount = await chirpie.connectBlueskyAccount({
  platform: "bluesky",
  identifier: "yourhandle.bsky.social",
  app_password: "xxxx-xxxx-xxxx-xxxx",
});

// Connect a LinkedIn account (starts OAuth flow)
const { authorization_url: linkedinUrl } = await chirpie.connectLinkedInAccount();

// Connect a Threads account (starts Meta OAuth flow)
const { authorization_url: threadsUrl } = await chirpie.connectThreadsAccount();

// Connect a Mastodon account (starts OAuth flow)
const { authorization_url: mastodonUrl } = await chirpie.connectMastodonAccount({
  platform: "mastodon",
  instance_url: "https://mastodon.social",
});

// Connect an Instagram account (starts Instagram Login OAuth flow)
const { authorization_url: instagramUrl } = await chirpie.connectInstagramAccount();

// Connect a Facebook Page (starts Facebook Login OAuth flow)
const { authorization_url: facebookUrl } = await chirpie.connectFacebookAccount();

// Connect a Telegram bot (bot token auth)
const telegramAccount = await chirpie.connectTelegramAccount({
  platform: "telegram",
  bot_token: "123456789:ABCdefGHIjklMNOpqrSTUvwxYZ",
  chat_id: "-1001234567890",
});

// Reddit, Pinterest, TikTok, YouTube, Google Business Profile, Snapchat — Coming Soon

API Keys

// Create a key
const { key, prefix, name } = await chirpie.createKey("My Bot");

// List keys
const keys = await chirpie.listKeys();

// Revoke a key
await chirpie.revokeKey("key-uuid");

Analytics

const analytics = await chirpie.getPostAnalytics("post-uuid");
console.log(analytics.impressions, analytics.likes);

Error Handling

import { ChirpieClient, ChirpieApiError } from "@chirpie/sdk";

try {
  await chirpie.createPost({ ... });
} catch (err) {
  if (err instanceof ChirpieApiError) {
    console.error(err.code);     // "rate_limited"
    console.error(err.message);  // "Monthly post limit exceeded..."
    console.error(err.status);   // 429
  }
}

TypeScript Types

All types are exported:

import type {
  ApiPost,
  ApiThread,
  ApiAccount,
  ApiAnalytics,
  ApiKeyInfo,
  CreatePostInput,
  CreateThreadInput,
  ConnectMastodonInput,
  ConnectInstagramInput,
  ConnectFacebookInput,
  ConnectTelegramInput,
  ConnectRedditInput,
  ConnectPinterestInput,
  ConnectTikTokInput,
  ConnectYouTubeInput,
  ConnectGBPInput,
  ConnectSnapchatInput,
  ListPostsOptions,
} from "@chirpie/sdk";

On this page