---
title: TypeScript SDK
description: Build icon and Open Graph image URLs with @parsew/sdk.
---

`@parsew/sdk` builds image URLs (and fetches images) with typed options. It validates the domain and options before anything reaches the network.

```bash
npm install @parsew/sdk
```

```ts
import { ParsewBrands } from "@parsew/sdk/client";

const parsew = new ParsewBrands({ token: "pk_XXXXXXXXXXXX" });

// https://logo.parsew.com/stripe.com?token=pk_…&size=64&format=webp
parsew.url("stripe.com", { size: 64, format: "webp" });

// https://logo.parsew.com/og/stripe.com?token=pk_…&fallback=404
parsew.ogUrl("stripe.com");

// The bytes, for servers: { data: ArrayBuffer, contentType: string }
const { data, contentType } = await parsew.fetch("stripe.com", {
  theme: "dark",
});
```

## Options

| Option     | Type                       | Maps to       |
| ---------- | -------------------------- | ------------- |
| `size`     | `number` (1–2048)          | `size`        |
| `format`   | `"png" \| "webp" \| "jpg"` | `format`      |
| `theme`    | `"light" \| "dark"`        | `theme`       |
| `fallback` | `"monogram" \| "404"`      | `fallback`    |
| `retina`   | `boolean`                  | `retina=true` |
| `v`        | `string \| number`         | `v`           |

## Self-hosted deployments

Point the SDK at your own image API with `baseUrl`:

```ts
// A deployment with its own image host
new ParsewBrands({ token, baseUrl: "https://logo.example.com" });

// A workers.dev deployment: the image API is under /i
new ParsewBrands({ token, baseUrl: "https://parsew.example.workers.dev/i" });
```

Failed requests throw a `ParsewError` with the HTTP `status` and a `code` such as `HTTP_401` (see [Errors](/api/errors)).
