SDK Reference
Extraction
Structured data extraction from browser pages.
extract
extract<T>(options: ExtractOptions): Promise<ExtractionRunResult<T>>
Extract structured data from the current page using a schema.
const result = await opensteer.extract({
description: 'product-info',
schema: {
name: { type: 'string', description: 'Product name' },
price: { type: 'string', description: 'Product price' },
},
})
console.log(result.data) // { name: '...', price: '...' }
Array extraction:
const result = await opensteer.extract({
description: 'search-results',
schema: {
items: [{
title: { type: 'string' },
url: { type: 'string' },
}],
},
})
console.log(result.data.items) // [{ title: '...', url: '...' }, ...]
Schema field options:
| Option | Type | Description |
|---|---|---|
type | 'string' | 'number' | 'boolean' | Value type |
description | string | Field description for LLM |
element | number | Counter reference |
selector | string | CSS selector |
attribute | string | Element attribute to extract |
source | 'current_url' | Extract from page URL |
extractFromPlan
extractFromPlan<T>(options: ExtractFromPlanOptions): Promise<ExtractionRunResult<T>>
Extract data using a pre-planned extraction (persisted schema and selectors).
const result = await opensteer.extractFromPlan({
description: 'product-info',
schema: { name: { type: 'string' }, price: { type: 'string' } },
})
