Skip to content

Request Format

x-api-key: YOUR_API_KEY
Content-Type: application/json
{
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
}>
}

The schema field defines the JSON schema that describes the structure you want to extract from your documents.

{
"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"]
}

The contents array contains the files you want to process.

FieldTypeRequiredDescription
filenamestringNoOptional filename for the file
mimeTypestringYesMIME type of the file
datastringYesBase64-encoded file data
  • image/jpeg - JPEG images
  • image/png - PNG images
  • image/webp - WebP images
  • image/gif - GIF images
  • application/pdf - PDF documents
{
"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..."
}
]
}

All file data must be base64-encoded.

const fs = require("fs");
const data = fs.readFileSync("document.pdf");
const base64Data = data.toString("base64");
import base64
with open("document.pdf", "rb") as file:
base64_data = base64.b64encode(file.read()).decode("utf-8")
Terminal window
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\"
}]
}"