---
title: "TypeScript SDK"
description: "@rumoro-dev/sdk on npm. One typed function for each Rumoro API operation."
canonical: https://docs.rumoro.dev/sdks/typescript
markdown: https://docs.rumoro.dev/sdks/typescript.mdx
---

# TypeScript SDK

@rumoro-dev/sdk on npm. One typed function for each Rumoro API operation.

`@rumoro-dev/sdk` gives you one typed function for each endpoint, with the names from the [API reference](/api), such as `searchMentions`, `createKeyword` or `getAnalyticsSummary`. It is generated from the OpenAPI document, runs on Node 22 or newer and has no runtime dependencies. Use it on a server. The API doesn't accept requests from browsers on other sites, which keeps your [API key](/authentication) out of web pages.

```bash
npm install @rumoro-dev/sdk
```

## First call

```ts
import { createRumoro } from '@rumoro-dev/sdk';

const rumoro = createRumoro({ apiKey: process.env.RUMORO_API_KEY! });

const { data, error } = await rumoro.searchMentions({
  query: { platform: 'reddit', relevant: true, limit: 20 },
});
if (error) throw new Error(`${error.error.code}: ${error.error.message}`);

for (const mention of data.data) {
  console.log(mention.post.platform, mention.classification?.relevance, mention.post.url);
}
```

A call never throws on an HTTP error. It returns `{ data, error, request, response }`, and on failure `error` holds the API's [error envelope](/errors) while `data` is undefined. To get `data` directly and an exception on failure, pass `throwOnError: true`.

```ts
const { data: keyword } = await rumoro.createKeyword({
  body: { term: 'driftwood', kind: 'brand', platforms: ['reddit', 'github'] },
  throwOnError: true,
});
```

## Calls

Put ids from the path in `path`, query parameters in `query` and the request body in `body`.

```ts
await rumoro.updateMention({ path: { id: 'mm_...' }, body: { status: 'done', note: 'Answered in the thread' } });
await rumoro.getPerson({ path: { id: 'aut_...' } });
await rumoro.createAlert({
  body: { name: 'Pricing questions', mode: 'instant', event: 'mention.pricing', filter: { intents: ['pricing'] }, channelIds: ['dest_...'] },
});
await rumoro.getAnalyticsSummary({ query: { range: '7d', compare: true, timezone: 'America/New_York' } });
```

For the next page, send `nextCursor` as `cursor`. Stop when it is `null`.

```ts
let cursor: string | undefined;
do {
  const { data } = await rumoro.searchMentions({ query: { sentiment: 'negative', limit: 100, cursor }, throwOnError: true });
  for (const mention of data.data) console.log(mention.id, mention.post.url);
  cursor = data.nextCursor ?? undefined;
} while (cursor);
```

A CSV export returns a string.

```ts
const { data: csv } = await rumoro.exportMentionsCsv({ query: { since: '2026-10-01T00:00:00Z' }, throwOnError: true });
```

## Types

All schemas are exported, such as `Mention`, `Keyword`, `Person`, `Segment`, `Alert`, `Channel`, `Company`, `AnalyticsSummary` and `ShareOfVoice`. Every call also has an `<Operation>Data` and an `<Operation>Response` type.

```ts
import type { Mention, SearchMentionsData } from '@rumoro-dev/sdk';

type SearchQuery = NonNullable<SearchMentionsData['query']>;
const recent: SearchQuery = { relevant: true, limit: 50 };
```

## Configuration

```ts
const rumoro = createRumoro({
  apiKey: 'ref_...',
  baseUrl: 'https://api.rumoro.dev',        // the default
  fetch: customFetch,                       // for tests, or a runtime without fetch
  headers: { 'x-request-source': 'crm-sync' }, // added to every request
});
```

`rumoro.client` is the client underneath. Use `rumoro.client.interceptors` to change requests or responses, and `rumoro.client.request(...)` to send any request yourself.
