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 tweet in thread" },
    { text: "Second tweet in thread" },
    { text: "Third tweet in thread" },
  ],
  schedule_at: "2026-04-01T14:00:00Z",  // Optional
});

Accounts

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

// Start OAuth flow
const { authorization_url } = await chirpie.connectAccount();

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,
  ListPostsOptions,
} from "@chirpie/sdk";

On this page