TypeScript SDK
v1A 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.
DownloadInstall
Shell
npm install https://castrook.com/downloads/castrook-sdk-0.1.0.tgzInitialize 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); // queuedWalk 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
| Resource | Methods |
|---|---|
accounts | list, createTest, publishingOptions, disconnect |
posts | list, create, get, cancel |
comments | list, reply |
webhooks | list, create, disable |
deliveries | list |
logs | list |
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.