Developer Quickstart
Get up and running with the DataParse API in minutes. This guide will walk you through extracting structured data from a document with a complete working example.
Step 1: Get Your API Key
Section titled “Step 1: Get Your API Key”Create an API key in the dashboard - you’ll need this to authenticate your requests.
Step 2: Make Your First Request
Section titled “Step 2: Make Your First Request”Here’s a complete example that extracts invoice data from a PDF:
cURL Example
Section titled “cURL Example”curl -X POST https://api.datapar.se/v1/ \ -H "x-api-key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "schema": { "type": "object", "properties": { "invoice_number": { "type": "string", "description": "The unique invoice number or reference ID, typically found at the top of the invoice" }, "vendor_name": { "type": "string", "description": "The name of the company or individual who issued the invoice" }, "total_amount": { "type": "number", "description": "The final amount due including all taxes and fees, usually shown as 'Total' or 'Amount Due'" }, "date": { "type": "string", "description": "The invoice date in YYYY-MM-DD format" } }, "required": ["invoice_number", "total_amount", "date"] }, "contents": [{ "filename": "invoice.pdf", "mimeType": "application/pdf", "data": "BASE64_ENCODED_PDF_DATA" }] }'JavaScript Example
Section titled “JavaScript Example”const fs = require("fs");
// Read and encode your PDF fileconst pdfBuffer = fs.readFileSync("invoice.pdf");const base64Data = pdfBuffer.toString("base64");
// Make the API requestconst response = await fetch("https://api.datapar.se/v1/", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json", }, body: JSON.stringify({ schema: { type: "object", properties: { invoice_number: { type: "string", description: "The unique invoice number or reference ID, typically found at the top of the invoice", }, vendor_name: { type: "string", description: "The name of the company or individual who issued the invoice", }, total_amount: { type: "number", description: "The final amount due including all taxes and fees, usually shown as 'Total' or 'Amount Due'", }, date: { type: "string", description: "The invoice date in YYYY-MM-DD format", }, }, required: ["invoice_number", "total_amount", "date"], }, contents: [ { filename: "invoice.pdf", mimeType: "application/pdf", data: base64Data, }, ], }),});
const extractedData = await response.json();console.log("Extracted data:", extractedData);Python Example
Section titled “Python Example”import requestsimport base64
# Read and encode your PDF filewith open('invoice.pdf', 'rb') as file: base64_data = base64.b64encode(file.read()).decode('utf-8')
# Make the API requestresponse = requests.post( 'https://api.datapar.se/v1/', headers={ 'x-api-key': 'YOUR_API_KEY', 'Content-Type': 'application/json' }, json={ 'schema': { 'type': 'object', 'properties': { 'invoice_number': { 'type': 'string', 'description': 'The unique invoice number or reference ID, typically found at the top of the invoice' }, 'vendor_name': { 'type': 'string', 'description': 'The name of the company or individual who issued the invoice' }, 'total_amount': { 'type': 'number', 'description': 'The final amount due including all taxes and fees, usually shown as \'Total\' or \'Amount Due\'' }, 'date': { 'type': 'string', 'description': 'The invoice date in YYYY-MM-DD format' } }, 'required': ['invoice_number', 'total_amount', 'date'] }, 'contents': [{ 'filename': 'invoice.pdf', 'mimeType': 'application/pdf', 'data': base64_data }] })
extracted_data = response.json()print('Extracted data:', extracted_data)Step 3: Expected Response
Section titled “Step 3: Expected Response”You’ll receive structured JSON data matching your schema:
{ "invoice_number": "INV-2024-001", "vendor_name": "Acme Corporation", "total_amount": 1250.5, "date": "2024-01-15"}Next Steps
Section titled “Next Steps”- Learn more: Check out the API Reference for detailed documentation
- Schema design: Learn best practices for schema design to improve parsing accuracy
- See examples: Browse practical examples for common use cases
- Pricing: View our simple pricing - start with 100 pages free
Common Use Cases
Section titled “Common Use Cases”- Invoice Processing: Extract vendor, amount, date, line items
- Receipt Parsing: Get merchant, total, items, tax information
- Form Data: Extract structured data from filled forms
- Business Cards: Parse contact information from images
- Contracts: Extract key terms, dates, and parties
Ready to get started? Create your API key and try the examples above!