Request Format
Headers
Section titled “Headers”x-api-key: YOUR_API_KEYContent-Type: application/jsonRequest Body Schema
Section titled “Request Body Schema”{ schema: object, // JSON schema defining the structure to extract contents: Array<{ // Array of files to process filename?: string, // Optional filename mimeType: string, // MIME type of the file data: string // Base64-encoded file data }>}Schema Field
Section titled “Schema Field”The schema field defines the JSON schema that describes the structure you want to extract from your documents.
Example Schema
Section titled “Example Schema”{ "type": "object", "properties": { "invoice_number": { "type": "string", "description": "Unique invoice identifier, often prefixed with 'INV-' or similar" }, "vendor_name": { "type": "string", "description": "Name of the company or person who issued the invoice" }, "total_amount": { "type": "number", "description": "Final amount due including all taxes and fees" }, "date": { "type": "string", "description": "Invoice date in YYYY-MM-DD format" }, "line_items": { "type": "array", "description": "Individual products or services listed on the invoice", "items": { "type": "object", "properties": { "description": { "type": "string", "description": "Product or service description" }, "quantity": { "type": "number", "description": "Number of units" }, "price": { "type": "number", "description": "Price per unit" } } } } }, "required": ["invoice_number", "total_amount", "date"]}Contents Field
Section titled “Contents Field”The contents array contains the files you want to process.
Content Object Properties
Section titled “Content Object Properties”| Field | Type | Required | Description |
|---|---|---|---|
filename | string | No | Optional filename for the file |
mimeType | string | Yes | MIME type of the file |
data | string | Yes | Base64-encoded file data |
Supported MIME Types
Section titled “Supported MIME Types”image/jpeg- JPEG imagesimage/png- PNG imagesimage/webp- WebP imagesimage/gif- GIF imagesapplication/pdf- PDF documents
Complete Request Example
Section titled “Complete Request Example”{ "schema": { "type": "object", "properties": { "name": { "type": "string", "description": "Full name of the person" }, "email": { "type": "string", "description": "Email address", "format": "email" }, "phone": { "type": "string", "description": "Phone number" } }, "required": ["name", "email"] }, "contents": [ { "filename": "business_card.jpg", "mimeType": "image/jpeg", "data": "/9j/4AAQSkZJRgABAQEAYABgAAD..." } ]}Base64 Encoding
Section titled “Base64 Encoding”All file data must be base64-encoded.
JavaScript/Node.js
Section titled “JavaScript/Node.js”const fs = require("fs");const data = fs.readFileSync("document.pdf");const base64Data = data.toString("base64");Python
Section titled “Python”import base64
with open("document.pdf", "rb") as file: base64_data = base64.b64encode(file.read()).decode("utf-8")base64_data=$(base64 -i document.pdf)curl -X POST https://api.datapar.se/v1/ \ -H "x-api-key: your_api_key" \ -H "Content-Type: application/json" \ -d "{ \"schema\": {\"type\": \"object\"}, \"contents\": [{ \"mimeType\": \"application/pdf\", \"data\": \"$base64_data\" }] }"