TypeScript SDK
The official Orsa TypeScript SDK for Node.js and edge runtimes.
Installation
npm install orsa
# or
pnpm add orsa
# or
yarn add orsaRequirements: Node.js 18+ or any edge runtime with fetch support.
Quick Start
import Orsa from 'orsa';
const client = new Orsa({
apiKey: process.env.ORSA_API_KEY!,
});
const brand = await client.brand.retrieve({ domain: 'stripe.com' });
console.log(brand.data);Configuration
const client = new Orsa({
apiKey: 'orsa_live_...', // Required
baseUrl: 'https://api.orsa.dev', // Optional (default)
timeout: 30_000, // Optional: request timeout in ms
maxRetries: 3, // Optional: auto-retry on 5xx/network errors
});| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Your Orsa API key (required) |
baseUrl | string | https://api.orsa.dev | API base URL |
timeout | number | 30000 | Request timeout in ms |
maxRetries | number | 3 | Max retries on transient errors |
Namespaces
The SDK organizes methods into logical namespaces:
client.brand — Brand Intelligence
// Full brand data from domain
const brand = await client.brand.retrieve({ domain: 'stripe.com' });
// Simplified brand data (fewer fields, faster)
const simple = await client.brand.retrieveSimplified({ domain: 'stripe.com' });
// Lookup by company name
const byName = await client.brand.retrieveByName({ name: 'Stripe' });
// Lookup by email domain
const byEmail = await client.brand.retrieveByEmail({ email: 'support@stripe.com' });
// Lookup by stock ticker
const byTicker = await client.brand.retrieveByTicker({ ticker: 'AAPL' });
// Screenshot
const screenshot = await client.brand.screenshot({
domain: 'stripe.com',
fullPage: false,
darkMode: true,
});
// Style guide extraction
const style = await client.brand.styleguide({ domain: 'stripe.com' });
// Font detection
const fonts = await client.brand.fonts({ domain: 'stripe.com' });
// NAICS industry classification
const naics = await client.brand.naics({ domain: 'stripe.com' });
// Transaction identifier (fintech)
const txn = await client.brand.transactionIdentifier({
transaction_info: 'STRIPE* ACME CORP',
country_gl: 'US',
});client.web — Web Scraping
// Raw HTML
const html = await client.web.scrapeHtml({ url: 'https://example.com' });
// Clean Markdown
const md = await client.web.scrapeMarkdown({ url: 'https://example.com' });
// Image extraction
const images = await client.web.scrapeImages({ url: 'https://example.com' });
// Sitemap parsing
const sitemap = await client.web.scrapeSitemap({ domain: 'example.com' });
// Full site crawl
const crawl = await client.web.crawl({
url: 'https://example.com',
maxPages: 50,
maxDepth: 3,
urlRegex: '/blog/.*',
});
// Check crawl status
const status = await client.web.crawlStatus({ jobId: crawl.data.job_id });client.ai — AI Extraction
// Natural language query
const result = await client.ai.query({
domain: 'stripe.com',
data_to_extract: 'pricing plans with features and prices',
specific_pages: ['/pricing'],
});
// Extract products
const products = await client.ai.extractProducts({ domain: 'store.example.com' });
// Extract single product
const product = await client.ai.extractProduct({
url: 'https://store.example.com/product/123',
});client.utility — Utility
// Prefetch (warm cache)
await client.utility.prefetch({ domain: 'stripe.com' });
// Prefetch by email
await client.utility.prefetchByEmail({ email: 'user@stripe.com' });Error Handling
import Orsa, { OrsaError } from 'orsa';
try {
const brand = await client.brand.retrieve({ domain: 'invalid-domain' });
} catch (error) {
if (error instanceof OrsaError) {
console.log(error.message); // Human-readable message
console.log(error.statusCode); // HTTP status code
console.log(error.code); // Error code (e.g., "DOMAIN_UNREACHABLE")
}
}TypeScript Types
All response types are exported for use in your code:
import type {
BrandData,
BrandResponse,
ScrapeMarkdownResponse,
AIQueryResponse,
CrawlResponse,
ScreenshotResponse,
OrsaConfig,
} from 'orsa';Framework Examples
Next.js Server Component
import Orsa from 'orsa';
const client = new Orsa({ apiKey: process.env.ORSA_API_KEY! });
export default async function BrandPage({ params }: { params: { domain: string } }) {
const brand = await client.brand.retrieve({ domain: params.domain });
return (
<div>
<h1>{brand.data.title}</h1>
<p>{brand.data.description}</p>
</div>
);
}Express / Hono
import Orsa from 'orsa';
import { Hono } from 'hono';
const app = new Hono();
const orsa = new Orsa({ apiKey: process.env.ORSA_API_KEY! });
app.get('/brand/:domain', async (c) => {
const brand = await orsa.brand.retrieve({ domain: c.req.param('domain') });
return c.json(brand.data);
});