Extracta.ai
DashboardJoin Discord
  • extracta.ai
    • Introduction
    • Overview
  • API Reference
    • 🔓Authentication
    • 📁Supported File Types
  • Data Extraction - API
    • đŸ’ģAPI Endpoints - Data Extraction
      • 1. Create extraction
      • 2. View extraction
      • 3. Update extraction
      • 4. Delete extraction
      • 5. Upload Files
      • 6. Get results
    • Extraction Details
      • 🌎Supported Languages
      • âš™ī¸Options
      • 📋Fields
    • Receiving Batch Results
      • Polling vs Webhook
      • How to use the Webhook
    • đŸ•šī¸Postman Integration
  • Document Classification - API
    • đŸ’ģAPI Endpoints - Document Classification
      • 1. Create classification
      • 2. View classification
      • 3. Update classification
      • 4. Delete data
        • 4.1 Delete classification
        • 4.2 Delete batch
        • 4.3 Delete files
      • 5. Upload Files
      • 6. Get results
    • Classification Details
      • 📄Document Types
  • Documents
    • Custom Document
    • Resume / CV
    • Contract
    • Business Card
    • Email
    • Invoice
    • Receipt
    • Bank Statement
  • Support
    • 💁Tutorials
    • đŸŸĸAPI Status
  • Contact
    • 📧Contact Us
    • ❓FAQ
Powered by GitBook
On this page
  • Why Choose Extracta.ai for Invoice Parsing?
  • Getting Started
  • Body Example for Invoice
  • How to Apply This Template
  • Code Example
  • Conclusion

Was this helpful?

  1. Documents

Invoice

Transform the way you process invoices with Extracta.ai's cutting-edge document parsing capabilities. Our API is specifically designed to automate the extraction of detailed invoice data, facilitating faster, more accurate accounts payable and receivable processes. This guide provides you with a tailored request body for creating invoice extractions, making it easier to integrate our technology into your financial workflows.

Why Choose Extracta.ai for Invoice Parsing?

  • Efficient Processing: Automate the extraction of invoice data to accelerate your financial operations.

  • High Precision: Depend on our advanced OCR and machine learning technologies for accurate data capture.

  • Flexibility: Extract data from invoices in various formats, including PDF, PNG, and JPG.

  • Custom Extraction: Specify the data you need, from vendor details to line items, for tailored results.

Getting Started

To initiate invoice data extraction, execute a POST request to the /createExtraction endpoint using the following request body template. This template is pre-configured with keys for common invoice data points, ensuring a streamlined setup for your extraction needs.

Body Example for Invoice

JSON Body
{
    "extractionDetails": {
        "name": "Invoice - Extraction",
        "language": "English",
        "options": {
            "hasTable": true,
            "handwrittenTextRecognition": false
        },
        "fields": [
            {
                "key": "invoice_id",
                "example": "1234567890",
                "type": "string"
            },
            {
                "key": "invoice_date",
                "description": "the invoice date in the following format yyyy-mm-dd",
                "example": "2022-01-01",
                "type": "string"
            },
            {
                "key": "invoice_tax_rate",
                "description": "the tax rate of the invoice",
                "example": "19%",
                "type": "string"
            },
            {
                "key": "invoice_currency",
                "description": "the currency of the invoice. return one of the following: RON, EUR, USD, LEI, etc.",
                "example": "Lei",
                "type": "string"
            },
            {
                "key": "client",
                "description": "the client in the invoice",
                "type": "object",
                "properties": [
                    {
                        "key": "client_name",
                        "description": "name of the client",
                        "example": "NovaTech Innovations",
                        "type": "string"
                    },
                    {
                        "key": "client_address",
                        "description": "address of the client",
                        "example": "1234 Main St, New York, NY 10001",
                        "type": "string"
                    },
                    {
                        "key": "client_tax_id",
                        "description": "tax id or vat id of the client",
                        "example": "987654321",
                        "type": "string"
                    }
                ]
            },
            {
                "key": "merchant",
                "description": "the merchant in the invoice",
                "type": "object",
                "properties": [
                    {
                        "key": "merchant_name",
                        "description": "name of the merchant",
                        "example": "Galactic Solutions",
                        "type": "string"
                    },
                    {
                        "key": "merchant_address",
                        "description": "address of the merchant",
                        "example": "789 Elm Rd, Seattle, WA 98109",
                        "type": "string"
                    },
                    {
                        "key": "merchant_tax_id",
                        "description": "tax id or vat id of the merchant",
                        "example": "123987456",
                        "type": "string"
                    }
                ]
            },
            {
                "key": "items",
                "description": "the items in the invoice",
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": [
                        {
                            "key": "name",
                            "description": "the name of the item",
                            "example": "Item 1",
                            "type": "string"
                        },
                        {
                            "key": "quantity",
                            "description": "the quantity of the item",
                            "example": "1",
                            "type": "string"
                        },
                        {
                            "key": "unit_price",
                            "description": "the unit price of the item. return only the number as a string.",
                            "example": "100.00",
                            "type": "string"
                        },
                        {
                            "key": "total_price",
                            "description": "the total price of the item. return only the number as a string.",
                            "example": "100.00",
                            "type": "string"
                        },
                        {
                            "key": "tax",
                            "description": "the total tax of the item. return only the number as a string.",
                            "example": "100.00",
                            "type": "string"
                        }
                    ]
                }
            },
            {
                "key": "invoice_sub_total",
                "description": "The total amount before tax is applied. This may correspond to 'Total' or similar terms before tax addition. Return only the number as a string.",
                "example": "863.03",
                "type": "string"
            },
            {
                "key": "invoice_tax_amount",
                "description": "The amount of tax charged on the invoice. This is the tax figure listed separately from the sub-total. Return only the number as a string.",
                "example": "163.97",
                "type": "string"
            },
            {
                "key": "invoice_grand_total",
                "description": "The total amount after tax has been added. This should capture the final payable amount. Return only the number as a string.",
                "example": "1027.00",
                "type": "string"
            }
        ]
    },
    "file": "https://deveatery.com/extracta/invoice.png"
}
```

How to Apply This Template

  1. Craft Your API Request: Incorporate the JSON template in a POST request to /createExtraction. Remember to authenticate your request by including your API key as a Bearer token in the request header.

  2. Process the Extracted Data: Once the API processes your request, it will return structured data extracted from the invoice, ready for integration into your financial systems.

Code Example

const axios = require('axios');

/**
 * Initiates a new document extraction process with the provided details.
 * 
 * @param {string} token - The authorization token for API access.
 * @param {Object} extractionDetails - The details of the extraction to be created.
 * @returns {Promise<Object>} The promise that resolves to the API response with the new extraction ID.
 */
async function createExtraction(token, extractionDetails) {
    const url = "https://api.extracta.ai/api/v1/createExtraction";

    try {
        const response = await axios.post(url, {
            extractionDetails
        }, {
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${token}`
            }
        });

        // Handling response
        return response.data; // Directly return the parsed JSON response
    } catch (error) {
        // Handling errors
        throw error.response ? error.response.data : new Error('An unknown error occurred');
    }
}

async function main() {
    const token = 'apiKey';
    const extractionDetails = {}; // the json body from the example

    try {
        const response = await createExtraction(token, extractionDetails);
        console.log("New Extraction Created:", response);
    } catch (error) {
        console.error("Failed to create new extraction:", error);
    }
}

main();
import requests


def create_extraction(token, extraction_details):
    url = "https://api.extracta.ai/api/v1/createExtraction"
    headers = {"Content-Type": "application/json", "Authorization": f"Bearer {token}"}

    try:
        response = requests.post(url, json=extraction_details, headers=headers)
        response.raise_for_status()  # Raises an HTTPError if the response status code is 4XX/5XX
        return response.json()  # Returns the parsed JSON response
    except requests.RequestException as e:
        # Handles any requests-related errors
        print(e)
        return None


# Example usage
if __name__ == "__main__":
    token = "apiKey"
    extraction_details = {} # the json body from the example

    response = create_extraction(token, extraction_details)
    print("New Extraction Created:", response)

Conclusion

Leverage Extracta.ai to modernize your invoice processing, reducing manual data entry and enhancing the accuracy of your financial operations. Our API simplifies the task of digitizing, capturing, and structuring data from scanned invoices, allowing you to focus on strategic financial management.

Explore our API Endpoints - Data Extraction and 1. Create extraction pages for more insights on integrating Extracta.ai into your document processing workflow.

PreviousEmailNextReceipt

Last updated 1 year ago

Was this helpful?

Obtain an API Key: Sign up at and visit the /api page to generate your unique API key.

https://app.extracta.ai