@parsew/sdk
v0.9.0
Published
TypeScript SDK for [Parsew](https://parsew.com) — web scraping, structured extraction, branding intelligence, and logo CDN.
Readme
@parsew/sdk
TypeScript SDK for Parsew — web scraping, structured extraction, branding intelligence, and logo CDN.
Install
npm install @parsew/sdkEntrypoints
| Import | Use case | Auth |
|--------|----------|------|
| @parsew/sdk/server | Scrape, extract, map, brand (server-side) | sr_ secret key |
| @parsew/sdk/client | Logo URLs and fetches (browser-safe) | pk_ publishable key |
Server — Extract API
import { Parsew } from '@parsew/sdk/server'
const parsew = new Parsew({ apiKey: 'sr_...' })
// Scrape a page
const scrapeResult = await parsew.scrape('https://example.com')
console.log(scrapeResult.markdown)
// Extract structured data with a schema
const { data } = await parsew.extract('https://example.com/jobs/123', {
schema: z.object({
title: z.string(),
company: z.string(),
salary: z.number().optional(),
}),
prompt: 'Extract the job posting details',
})
// Discover URLs
const mapResult = await parsew.map('https://example.com/jobs', {
pattern: '/jobs/.*\\d+',
limit: 20,
})
console.log(mapResult.links)
// Extract branding
const brandResult = await parsew.brand('https://stripe.com')
console.log(brandResult.data.colors.primary)new Parsew(options)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | required | Your secret API key (sr_ prefix) |
| baseUrl | string | https://api.parsew.com | API base URL |
| timeout | number | 60000 | Request timeout in ms |
Client — Logo API
import { ParsewBrands } from '@parsew/sdk/client'
const brands = new ParsewBrands({ token: 'pk_...' })
// Build a URL for <img> tags
const url = brands.url('stripe.com', { size: 256, format: 'webp' })
// Fetch programmatically
const logo = await brands.fetch('stripe.com', { size: 512 })
console.log(logo.contentType) // "image/png"
console.log(logo.data) // ArrayBuffernew ParsewBrands(options)
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| token | string | required | Your publishable key (pk_ prefix) |
| baseUrl | string | https://logo.parsew.com | Logo API base URL |
| timeout | number | 30000 | Fetch timeout in ms |
brands.url(domain, options?)
Returns a logo URL string. Normalizes the domain automatically.
| Option | Type | Description |
|--------|------|-------------|
| size | number | Image size 1–2048 |
| format | 'jpg' \| 'png' \| 'webp' | Image format |
| fallback | 'monogram' \| '404' | What to return when no logo is found |
| retina | boolean | Double size for high-DPI displays |
| v | string \| number | Cache bust version |
Note: When the server has an SVG logo, it returns
image/svg+xmldirectly —size,format, andretinahave no effect for SVG logos.
brands.fetch(domain, options?)
Fetches the logo. Returns { data: ArrayBuffer, contentType: string }. Throws ParsewError on HTTP errors.
Error Handling
import { Parsew, ParsewError } from '@parsew/sdk/server'
// or
import { ParsewBrands, ParsewError } from '@parsew/sdk/client'
try {
await parsew.scrape('https://example.com')
} catch (err) {
if (err instanceof ParsewError) {
console.log(err.status) // HTTP status code
console.log(err.code) // Error code (e.g. "HTTP_504")
console.log(err.message) // Error message
}
}License
MIT
