Get Started
Quickstart
Get up and running with Parsew in under 5 minutes.
Install the SDK
npm install @parsew/sdk zod zod-to-json-schemanpm install @parsew/sdk valibotnpm install @parsew/sdk arktypeInitialize the client
import { Parsew } from '@parsew/sdk/server'
const parsew = new Parsew({
apiKey: 'sr_...',
})Scrape a page
const result = await parsew.scrape('https://example.com')
console.log(result.markdown) // Page content as Markdown
console.log(result.links) // All links found on the pageExtract structured data
Define a schema with your preferred validation library and pass it to extract().
Any library that implements standard-schema works out of the box.
import { z } from 'zod'
const result = await parsew.extract('https://example.com/product', {
schema: z.object({
title: z.string(),
price: z.number(),
inStock: z.boolean(),
}),
prompt: 'Extract the product details',
})
console.log(result.data) // { title: "...", price: 29.99, inStock: true }import * as v from 'valibot'
const result = await parsew.extract('https://example.com/product', {
schema: v.object({
title: v.string(),
price: v.number(),
inStock: v.boolean(),
}),
prompt: 'Extract the product details',
})
console.log(result.data) // { title: "...", price: 29.99, inStock: true }import { type } from 'arktype'
const result = await parsew.extract('https://example.com/product', {
schema: type({
title: 'string',
price: 'number',
inStock: 'boolean',
}),
prompt: 'Extract the product details',
})
console.log(result.data) // { title: "...", price: 29.99, inStock: true }Search the web
const result = await parsew.search('best web scraping APIs', { limit: 5 })
for (const r of result.results) {
console.log(r.title, r.url)
}Pass formats: ['markdown'] to also scrape each result and return its content inline (each scraped result costs 1 additional credit). Use tbs for time filters (d/w/m/y), filter for site: operators, and lang/country/location for locale.
const result = await parsew.search('claude code', {
tbs: 'w', // past week
filter: 'site:github.com',
formats: ['markdown'], // also scrape each result
limit: 5,
})
for (const r of result.results) {
console.log(r.url, r.markdown?.slice(0, 100))
}Analyze a brand
const result = await parsew.brand('https://stripe.com')
console.log(result.data.colors) // Primary, secondary, accent, etc.
console.log(result.data.typography) // Font families, sizes
console.log(result.data.images) // Logo, favicon, OG imageGet a logo URL
import { ParsewBrands } from '@parsew/sdk/client'
const brands = new ParsewBrands({ token: 'pk_...' })
// Build a URL for an <img> tag
const url = brands.url('stripe.com', { size: 256, format: 'webp' })
// Or fetch the logo programmatically
const logo = await brands.fetch('stripe.com', { size: 512 })
console.log(logo.contentType) // "image/png"
console.log(logo.data) // ArrayBufferGet an OG image URL
import { ParsewBrands } from '@parsew/sdk/client'
const brands = new ParsewBrands({ token: 'pk_...' })
// Build a URL for an <img> tag
const url = brands.ogUrl('stripe.com', { size: 1200, format: 'webp' })
// Or fetch the OG image programmatically
const og = await brands.fetchOg('stripe.com', { size: 1200 })
console.log(og.contentType) // "image/png"