Skip to content
Parsew Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

TypeScript SDK

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.

npm install @parsew/sdk
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:

// 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).

Was this page helpful?