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
  • Server URL
  • Headers
  • Body
  • Body Example
  • âš ī¸ Important
  • Code Example
  • Responses

Was this helpful?

  1. Document Classification - API
  2. API Endpoints - Document Classification

6. Get results

POST /documentClassification/getResults

This endpoint retrieves the classification results for a specific batch of documents.

By providing the classificationId and batchId, you can obtain the predicted document types for each file in the batch,.

Optionally, including a fileId will return results for that specific file only. This is useful for retrieving targeted results without querying the entire batch.

Server URL

https://api.extracta.ai/api/v1

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Required
Description

classificationId

string

true

The ID of the classification.

batchId

string

true

The ID of the batch.

fileId

string

false

The ID of the file.

Body Example

{
    "classificationId": "classificationId",
    "batchId": "batchId",
    "fileId": "fileId" // optional
}

âš ī¸ Important

To avoid rate-limiting, please ensure a delay of 2 seconds between consecutive requests to this endpoint.

Code Example

const axios = require('axios');

async function getClassificationResults(token, classificationId, batchId, fileId) {
    const url = "https://api.extracta.ai/api/v1/documentClassification/getResults";

    try {
        const payload = {
            classificationId,
            batchId
        };

        if (fileId) {
            payload.fileId = fileId;
        }

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

        return response.data;
    } catch (error) {
        throw error.response ? error.response.data : new Error('An unknown error occurred');
    }
}

async function main() {
    const token = 'apiKey';
    const classificationId = 'classificationId';
    const batchId = 'batchId';
    const fileId = null; // or provide a specific file ID

    try {
        const results = await getClassificationResults(token, classificationId, batchId, fileId);
        console.log("Classification Results:", results);
    } catch (error) {
        console.error("Failed to retrieve classification results:", error);
    }
}

main();
import requests

def get_classification_results(token, classification_id, batch_id, file_id=None):
    url = "https://api.extracta.ai/api/v1/documentClassification/getResults"
    
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {token}'
    }
    
    payload = {
        'classificationId': classification_id,
        'batchId': batch_id
    }

    if file_id:
        payload['fileId'] = file_id

    response = requests.post(url, json=payload, headers=headers)
    
    if response.status_code == 200:
        return response.json()
    else:
        response.raise_for_status()

# Example usage
if __name__ == "__main__":
    token = 'apiKey'
    classification_id = 'classificationId'
    batch_id = 'batchId'
    file_id = None  # Or use a specific file ID like 'file123'

    try:
        results = get_classification_results(token, classification_id, batch_id, file_id)
        print("Classification Results:", results)
    except Exception as e:
        print("Failed to retrieve classification results:", e)
<?php

function getClassificationResults($token, $classificationId, $batchId, $fileId = null) {
    $url = 'https://api.extracta.ai/api/v1/documentClassification/getResults';

    // Initialize cURL session
    $ch = curl_init($url);
    
    // Prepare the payload
    $payload = [
        'classificationId' => $classificationId,
        'batchId' => $batchId
    ];

    if ($fileId !== null) {
        $payload['fileId'] = $fileId;
    }

    $payload = json_encode($payload);

    // Set cURL options
    curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $token,
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, 1);

    try {
        $response = curl_exec($ch);

        if (curl_errno($ch)) {
            throw new Exception('Curl error: ' . curl_error($ch));
        }

        return $response;
    } catch (Exception $e) {
        return 'Error: ' . $e->getMessage();
    } finally {
        curl_close($ch);
    }
}

// Example usage
$token = 'apiKey';
$classificationId = 'classificationId';
$batchId = 'batchId';
$fileId = null; // or 'yourFileId' if you want to filter by file

try {
    $results = getClassificationResults($token, $classificationId, $batchId, $fileId);
    echo $results;
} catch (Exception $e) {
    echo "Failed to retrieve classification results: " . $e->getMessage();
}

?>

Responses

{
    "status": "success",
    "classificationId": "classificationId",
    "batchId": "batchId",
    "files": [
        {
            "fileId": "fileId1",
            "fileName": "File 1.pdf",
            "status": "processed",
            "result": {
                "confidence": 0.9,
                "documentType": "invoice"
            },
            "url": "fileUrl"
        },
        {
            "fileId": "fileId2",
            "fileName": "File 2.pdf",
            "status": "processed",
            "result": {
                "confidence": 0.95,
                "documentType": "other"
            },
            "url": "fileUrl"
        },
        ...
    ]
}
{
    "status": "success",
    "classificationId": "classificationId",
    "batchId": "batchId",
    "fileId": "fileId",
    "files": [
        {
            "fileId": "fileId",
            "fileName": "File 1.pdf",
            "status": "processed",
            "result": {
                "confidence": 0.9,
                "documentType": "invoice"
            },
            "url": "fileUrl"
        }
    ]
}
{
    "status": "waiting",
    "classificationId": "-OPXQuIrkHuA2QZkY-44",
    "batchId": "8pMpPs6SMPBpcnnznoaRz8bsj"
}
{
    "status": "error",
    "message": "Internal server error"
}
Previous5. Upload FilesNextClassification Details

Last updated 16 hours ago

Was this helpful?

đŸ’ģ