> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vibechain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> @vibechain/sdk: a typed client for the public vibe.market API, for Node.js and browsers.

> [!WARNING]
>
> The SDK calls an **experimental protocol's** API. Follow the [Terms](https://vibechain.com/terms), treat indexed reads as potentially delayed and revalidate before wallet transactions.

[`@vibechain/sdk`](https://www.npmjs.com/package/@vibechain/sdk) is the official TypeScript client for the [vibe.market API](https://docs.vibechain.com/api-reference/vibemarket-intro.md). Every documented operation is typed from the same OpenAPI schema this site publishes, so paths, parameters, request bodies and responses are checked by the compiler.

| | |
| - | - |
| Package | [`@vibechain/sdk`](https://www.npmjs.com/package/@vibechain/sdk) on npm |
| License | MIT |
| Module formats | ESM and CommonJS, with type declarations for both |
| Runtimes | Modern browsers and Node.js `^22.23.4`, `^24.22.1` or `^26.12.1` |

## Install

```bash theme={null}
npm install @vibechain/sdk
```

## First request

Register your own key first; see [authentication and limits](https://docs.vibechain.com/docs/vibemarket/authentication.md). The SDK sends it as the `API-KEY` header.

```ts theme={null}
import { createVibechainClient, VibechainApiError } from "@vibechain/sdk";

const market = createVibechainClient({ apiKey: process.env.VIBECHAIN_API_KEY! });

const { data: registry } = await market.GET("/runtime/versions", {
  signal: AbortSignal.timeout(15_000),
});
console.log(registry?.versions);
```

A key identifies application quota. It never replaces wallet consent, and a key shipped in browser code is visible to that browser's user.

## Discover the graph, then read

`GET` and `POST` take the literal paths from the [API reference](https://docs.vibechain.com/api-reference/vibemarket-intro.md). The client picks the correct host for each operation: website discovery routes go to `https://vibechain.com/api/vibemarket2`, runtime and creator routes to `https://build.vibechain.com/api/vibemarket2`.

```ts theme={null}
const { data: sources } = await market.GET("/catalog/sources");

const { data: resolved } = await market.GET("/runtime/pack-slugs/{slug}", {
  params: { path: { slug: "your-pack-slug" } },
});

if (resolved) {
  const { data: page } = await market.GET("/runtime/{version}/catalog", {
    params: { path: { version: resolved.graph.id }, query: { after: "0" } },
  });
  console.log(page);
}
```

Do not hardcode the newest runtime or move an existing pack to another graph. The rules in [reading the market](https://docs.vibechain.com/docs/vibemarket/api.md) and [developer integration](https://docs.vibechain.com/docs/vibemarket/developers.md) apply unchanged when you call through the SDK.

The generated `paths`, `operations` and `components` types are exported for your own models:

```ts theme={null}
import type { components } from "@vibechain/sdk";

type Graph = components["schemas"]["Graph"];
```

Blockchain integers and wei stay strings; use `BigInt` or exact decimal arithmetic. Keep opaque `next` cursors intact and scoped to the same graph, resource and wallet.

## Errors and request budgets

Successful calls return `{ data, response }`. Any non-2xx status throws `VibechainApiError`, whose `body` is `unknown` because a gateway can answer with JSON, HTML or plain text.

```ts theme={null}
try {
  await market.GET("/runtime/versions", { signal: AbortSignal.timeout(15_000) });
} catch (error) {
  if (error instanceof VibechainApiError) {
    console.error(error.status, error.response.headers.get("Retry-After"));
  }
  throw error;
}
```

The SDK makes exactly one request per call. It does not retry, reconnect, poll or send telemetry. Read the rate-limit headers, honor `Retry-After` and add bounded backoff where your application needs it. Pass an `AbortSignal` to bound each wait.

Redirects are not followed, so your key is never sent to an artwork or CDN host. A redirect raises `VibechainApiError`; validate its `Location` header yourself and fetch the public image without the key.

## Uploads and creator actions

Binary form fields are typed as `Blob`. Use the exported `toFormData` serializer for the multipart operations and let fetch set the boundary.

```ts theme={null}
import { toFormData } from "@vibechain/sdk";

await market.POST("/support/image/upload", {
  body: { files: new Blob([imageBytes], { type: "image/png" }) },
  bodySerializer: toFormData,
});
```

Signed creator releases use `POST /releases` with the body described in the [creator guide](https://docs.vibechain.com/docs/vibemarket/creators.md). Construct and sign the action exactly as that guide requires; the SDK serializes it without reordering fields.

## Live updates

Request the stream route with `parseAs: "stream"` to receive raw server-sent-event bytes. Event parsing, resume IDs, `reset` handling and reconnect backoff belong to your application. Stream events are not transaction finality.

## What the SDK does not do

* It contains no wallet, signer or contract client. It cannot buy packs, launch pools, approve allowances, open cards or transfer assets.
* It does not register API keys or make chain-RPC calls.
* It covers only the public vibe.market API in this reference. First-party account, chat and moderation APIs are not included.

For contract interfaces, see the [contract ABI guide](https://docs.vibechain.com/docs/vibemarket/contracts.md).

## Building for VibeMarket OS instead?

Apps and games that run inside VibeMarket OS use a different package, [`@vibechain/os`](https://www.npmjs.com/package/@vibechain/os). Its reference is at [vibechain.com/os/docs](https://vibechain.com/os/docs).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.