Get Started
One function. Any input. Structured output.
npm install everythingstructured
import structure from 'everythingstructured'const result = await structure.run({input: 'Sarah Chen, Senior PM at Acme. Email: sarah@acme.com',output: { name: 'string', title: 'string', email: 'string' }})// → { name: "Sarah Chen", title: "Senior PM", email: "sarah@acme.com" }
That's it. Pass any input, define the output shape, get structured data back.
Input
Pass anything. The type is detected automatically.
Output
Define what comes back. Text, structured data, or a file.
Pass a format string to convert your input:
'text'Plain text'markdown'Headings, lists, tables'json'Valid JSON'csv'With header row'yaml'Valid YAML'xml'Well-formed XML'html'Semantic HTML'table'Markdown pipe table'list'Bulleted list'summary'Concise summary'pdf'PDF document'docx'Word document'xlsx'Excel spreadsheet'pptx'PowerPoint presentationawait structure.run({ input: 'https://example.com', output: 'markdown' })
await structure.run({ input: 'https://example.com/report.pdf', output: 'xlsx' })
File outputs
When the output is pdf, docx, xlsx, or pptx, the response contains a file instead of text:
const result = await structure.run({input: 'name,age\nAlice,30\nBob,25',output: 'xlsx'})// result.file.data → base64-encoded file// result.file.filename → "output.xlsx"// result.file.mime → "application/vnd...spreadsheetml.sheet"// result.file.size → 5847// Save it:import fs from 'fs'fs.writeFileSync(result.file.filename, Buffer.from(result.file.data, 'base64'))
doc generates DOCX. xls generates XLSX. ppt generates PPTX. Same function, same API.
Or pass a schema object to define the exact shape:
await structure.run({input: 'Sarah Chen, Senior PM at Acme. sarah@acme.com',output: { name: 'string', title: 'string', email: 'string' }})// → { name: "Sarah Chen", title: "Senior PM", email: "sarah@acme.com" }
output: {company: {name: 'string',address: {city: 'string',state: 'string'}}}
// Extracts all matchesoutput: {people: [{name: 'string',role: 'string'}]]}
Missing fields return null. Empty arrays return []. Data is never invented.
Supported types:
'string'Text'number'Float'integer'Integer'boolean'true / false'date'ISO 8601 date'datetime'ISO 8601 datetime'email'Email address'url'URL'phone'Phone number'object'Freeform JSON object'string[]'Array of strings[{ ... }]Array of typed objectsYou can also pass instructions and example
Both are optional. Use them when the schema alone isn't enough. Works with all output types — text, schemas, and files.
instructions — plain english rules for how to process the data:
await structure.run({input: 'Call me at 5551234567',output: { phone: 'string' },instructions: 'Format phone as (XXX) XXX-XXXX'})// → { phone: "(555) 123-4567" }
await structure.run({input: 'The AI market will reach 190 billion by 2025...',output: 'summary',instructions: 'Exactly 3 bullet points'})
await structure.run({input: 'Q1: $2.1B revenue, 34% growth, 3 product launches...',output: 'pptx',instructions: 'Create a 4-slide executive summary presentation'})
example — one correct output to show the exact structure you expect:
await structure.run({input: 'Find urgent emails from humans',output: { filter: { must: [{ key: 'string', match: 'object' }]] } },example: {filter: {must: [{ key: 'classification.sender.is_human', match: { value: true } },{ key: 'classification.action.leaf', match: { value: 'reply.urgent' } }]}}})
await structure.run({input: 'Menu: Burger $12.99, Salad $8.50, Soup $6.00',output: { items: [{ name: 'string', price: 'string' }]] },example: { items: [{ name: 'Burger', price: '$12.99' }]] }})// One example item → the API extracts all of them
You can use both together:
await structure.run({input: 'Create label suggestions for investor emails',output: {suggestions: [{name: 'string',filter: { must: [{ key: 'string', match: 'object' }]] },color: 'string'}]]},instructions: 'Generate 2-3 suggestions. Keys start with classification.',example: {suggestions: [{name: 'VIP Investors',filter: {must: [{ key: 'classification.relationship.leaf', match: { any: ['external.investor_advisor'] } }]]},color: 'ember'}]]}})
Examples
await structure.run({input: 'Sarah Chen, Senior PM at Acme. Email: sarah@acme.com',output: { name: 'string', title: 'string', email: 'string' }})// → { name: "Sarah Chen", title: "Senior PM", email: "sarah@acme.com" }
await structure.run({input: 'https://api.github.com/repos/vercel/next.js',output: { name: 'string', stars: 'number', language: 'string' }})// → { name: "next.js", stars: 128000, language: "JavaScript" }
await structure.run({input: 'https://example.com/invoice.pdf',output: {vendor: 'string',total: 'number',items: [{ name: 'string', price: 'number' }]]}})// → { vendor: "Acme Corp", total: 1490, items: [...] }
await structure.run({input: 'https://example.com/screenshot.png',output: 'text'})// → "Settings > Privacy > Location Services..."
await structure.run({input: 'https://example.com/receipt.jpg',output: {vendor: 'string',total: 'string',items: [{ name: 'string', price: 'string' }]]}})// → { vendor: "Whole Foods", total: "$47.23", items: [...] }
await structure.run({input: 'https://example.com/meeting.mp3',output: 'text'})// → "Welcome everyone to the Q1 planning meeting..."
await structure.run({input: 'https://example.com/report.xlsx',output: 'json'})// → [{ quarter: "Q1", revenue: 1200000 }, ...]
const result = await structure.run({input: '# Meeting Notes\n\n- Ship mobile app\n- Hire 3 engineers',output: 'pdf'})// → { file: { data: "base64...", filename: "output.pdf", size: 12400 } }
const result = await structure.run({input: 'name,age\nAlice,30\nBob,25',output: 'xlsx'})// → { file: { data: "base64...", filename: "output.xlsx", size: 5847 } }
const result = await structure.run({input: { title: 'Brief', client: 'BigCo', items: ['Auth', 'Dashboard'] },output: 'docx'})// → { file: { data: "base64...", filename: "output.docx", size: 8200 } }
await structure.run({input: 'Acme Corp: Engineering (50 people, lead: Alice), Design (20, lead: Bob)',output: {company: {name: 'string',departments: [{ name: 'string', headcount: 'number', lead: 'string' }]]}}})// → { company: { name: "Acme Corp", departments: [...] } }
REST API
Use any language.
curl -X POST https://api.everythingstructured.com/v1/run \-H "Content-Type: application/json" \-H "Authorization: Bearer sk-xxx" \-d '{"input": "Sarah Chen, Senior PM at Acme. Email: sarah@acme.com","output": { "name": "string", "email": "string" }}'
curl -X POST https://api.everythingstructured.com/v1/run \-H "Content-Type: application/json" \-H "Authorization: Bearer sk-xxx" \-d '{"input": "name,age\nAlice,30\nBob,25","output": "xlsx"}'// → { "file": { "data": "base64...", "filename": "output.xlsx", ... } }
curl -X POST https://api.everythingstructured.com/v1/run \-H "Content-Type: application/json" \-H "Authorization: Bearer sk-xxx" \-d '{"input": "Find urgent emails from humans","output": {"filter": { "must": [{ "key": "string", "match": "object" }]] }},"instructions": "Keys must start with classification.","example": {"filter": {"must": [{ "key": "classification.sender.is_human", "match": { "value": true } }]]}}}'
Errors
try {const result = await structure.run({ input: '...', output: { title: 'string' } })} catch (e) {console.error(e.code, e.message)}
INPUT_REQUIRED400Missing input fieldOUTPUT_REQUIRED400Missing output fieldAUTH_MISSING401No API key providedAUTH_INVALID_KEY401Invalid API keyINSUFFICIENT_CREDITS402Not enough creditsRATE_LIMIT_EXCEEDED429Too many requests per minuteINPUT_TOO_LARGE413Input exceeds size limitINPUT_UNREACHABLE422URL can't be fetchedINPUT_PARSE_FAILED422File couldn't be parsedPROCESSING_FAILED502Processing failed — retryTIMEOUT504Request took too longMetadata
Available after every call.
await structure.run({ input: 'https://example.com', output: 'text' })console.log(structure.meta?.duration) // "1234ms"console.log(structure.meta?.request_id) // "e3b1f2b4-..."console.log(structure.meta?.input_type) // "html"
request_idUnique request IDinput_typeDetected input typeoutput_typeOutput format useddurationProcessing timecredits_usedCredits consumedcredits_remainingRemaining balancechunkedInput was splitchunksNumber of chunkstruncatedContent was omittedwarningsProcessing warningsfile_conversionFile was generatedConfig
# .env — the SDK reads this automaticallySTRUCTURE_API_KEY=sk-xxx
Or pass it directly:
import { Structure } from 'everythingstructured'const structure = new Structure({ apiKey: 'sk-xxx' })