Quickstart
Get up and running with Structurify in 5 minutes. This guide shows you how to extract data from a document using either Python or Node.js.
Prerequisites
- A Structurify API key (get one from app.structurify.ai)
- Python 3.8+ or Node.js 18+
Installation
- Python
- Node.js
pip install structurify
npm install @structurify/sdk
Extract Data from a Document
- Python
- Node.js
- cURL
from structurify import Structurify
# Initialize client
client = Structurify(api_key="sk_live_your_api_key")
# Create a project with the invoice template
project = client.projects.create(
name="My First Project",
template_id="tpl_invoice"
)
# Upload a document
doc = client.documents.upload(
project_id=project["id"],
file_path="invoice.pdf"
)
# Run extraction
job = client.extraction.run(project_id=project["id"])
# Wait for completion
completed = client.extraction.wait_for_completion(job["id"])
print(f"Status: {completed['status']}")
# Export results as CSV
export = client.exports.create(
project_id=project["id"],
format="csv"
)
csv_data = client.exports.download(export["export"]["id"])
print(csv_data)
import { Structurify } from '@structurify/sdk';
import * as fs from 'fs';
// Initialize client
const client = new Structurify({ apiKey: 'sk_live_your_api_key' });
// Create a project with the invoice template
const project = await client.projects.create({
name: 'My First Project',
templateId: 'tpl_invoice',
});
// Upload a document
const doc = await client.documents.upload({
projectId: project.id,
file: new Blob([fs.readFileSync('invoice.pdf')]),
name: 'invoice.pdf',
});
// Run extraction
const job = await client.extraction.run({ projectId: project.id });
// Wait for completion
const completed = await client.extraction.waitForCompletion(job.id);
console.log(`Status: ${completed.status}`);
// Export results as CSV
const exportResult = await client.exports.create({
projectId: project.id,
format: 'csv',
});
const csvData = await client.exports.download(exportResult.export.id);
console.log(csvData);
# Set your API key
export API_KEY="sk_live_your_api_key"
# Create a project
curl -X POST https://app.structurify.ai/api/projects \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "My First Project", "templateId": "tpl_invoice"}'
# Upload a document (use the project ID from above)
curl -X POST https://app.structurify.ai/api/documents \
-H "Authorization: Bearer $API_KEY" \
-F "projectId=proj_xxx" \
-F "file=@invoice.pdf"
# Run extraction
curl -X POST https://app.structurify.ai/api/extraction-jobs \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"projectId": "proj_xxx"}'
# Check job status (use the job ID from above)
curl https://app.structurify.ai/api/extraction-jobs/job_xxx \
-H "Authorization: Bearer $API_KEY"
# Export results
curl -X POST https://app.structurify.ai/api/exports \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"projectId": "proj_xxx", "format": "csv"}'
Next Steps
- Authentication - Learn about API keys and security
- Python SDK - Complete Python SDK documentation
- Node.js SDK - Complete Node.js SDK documentation
- API Reference - Interactive API explorer
- Templates - Browse all 169 document templates
Try it Online
Don't want to write code? Try our web interface at structurify.ai/extract or use our Google Colab notebooks.