Skip to main content

TypeScript SDK

A zero-dependency, single-file TypeScript SDK for the Ranked AI REST API v1. Works anywhere fetch is available — Node 18+, Deno, Bun, and modern browsers.

Installation

The SDK is a single file with no external dependencies. Copy it directly into your project:
Or, when the package is published to npm:
Then import the client:

Quick start

Configuration

Error handling

Every failed request throws a RankedAIError with the HTTP status, error code, and request ID:

Pagination

All list endpoints return paginated responses. The meta.pagination object tells you whether more data is available:

Manual pagination

Auto-pagination iterator

The SDK provides a built-in paginate helper that yields every item across all pages:
This works with any paginated method:

Endpoints

Projects

Keywords (Rankings)

AI Prompts

Audits

Content

Reports

Webhooks

Webhook signature verification

When your server receives a webhook, verify the signature to confirm it was sent by Ranked AI. The signature is in the X-Webhook-Signature header as sha256=<hex>.

Node.js / Bun

Edge runtimes (Cloudflare Workers, Vercel Edge)

Use the async variant which uses the Web Crypto API:

Webhook event types

Webhook payload shape

TypeScript types

All types are exported from the SDK module and can be used directly: