DocumentationTypeScript SDK

TypeScript SDK

v1

A typed client for Node.js 20+ and modern server runtimes. Zero runtime dependencies.

@castrook/sdk · 0.1.0Distributed as a tarball. Not yet published to the npm registry.
Download

Install

Shell
npm install https://castrook.com/downloads/castrook-sdk-0.1.0.tgz

Initialize on your server

TypeScript
import { Castrook, CastrookError } from '@castrook/sdk';

const castrook = new Castrook({
  apiKey: process.env.CASTROOK_API_KEY!,
  baseURL: 'https://castrook.com/api/v1',
});

Publish with a typed response

TypeScript
const { data: post } = await castrook.posts.create({
  text: 'Hello from Castrook.',
  account_ids: [account.id],
  media: {
    type: 'video',
    url: 'https://your-cdn.com/hello.mp4',
  },
}, { idempotencyKey: 'my-first-post-v1' });

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

Walk a list

TypeScript
for await (const post of castrook.paginate(cursor =>
  castrook.posts.list({ cursor })
)) {
  console.log(post.id, post.status, post.targets);
}

Available resources

ResourceMethods
accountslist, createTest, publishingOptions, disconnect
postslist, create, get, cancel
commentslist, reply
webhookslist, create, disable
deliverieslist
logslist

Responses preserve the API’s { data, meta? } envelope. CastrookError exposes the API error code and request ID. The client supports request cancellation and retries safe requests; set maxRetries: 0 to disable retries.

Other languages

Use native HTTP clients or generate a typed client from the OpenAPI specification. Authentication, pagination, idempotency, and error behavior are identical.