6. Get batch results

POST /getBatchResults

This endpoint retrieves the results for a specific batch of documents. By providing the extractionId and batchId, you can obtain the processed data or the current status of the batch, indicating whether the processing is complete or still in progress.

Postman Collection

For a complete and interactive set of API requests, please refer to our Postman Integrationcollection.

Server URL

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

Headers

NameValue

Content-Type

application/json

Authorization

Bearer <token>

Body

NameTypeRequiredDescription

extractionId

string

true

The ID of the extraction used for processing the files.

batchId

string

true

The ID of the document batch submitted for extraction.

Body Example

{
    "extractionId": "extractionId",
    "batchId": "batchId"
}

Code Example

const axios = require('axios');

/**
 * Retrieves the results for a specific batch of documents.
 * 
 * @param {string} token - The authorization token for API access.
 * @param {string} extractionId - The unique identifier for the extraction.
 * @param {string} batchId - The unique identifier for the batch.
 * @returns {Promise<Object>} The promise that resolves to the batch results.
 */
async function getBatchResults(token, extractionId, batchId) {
    const url = "https://api.extracta.ai/api/v1/getBatchResults";

    try {
        const response = await axios.post(url, {
            extractionId,
            batchId
        }, {
            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 extractionId = 'extractionId';
    const batchId = 'apiKey';

    try {
        const batchResults = await getBatchResults(token, extractionId, batchId);
        console.log("Batch Results:", batchResults);
    } catch (error) {
        console.error("Failed to retrieve batch results:", error);
    }
}

main();

Responses

{
    "extractionId": "extractionId",
    "batchId": "batchId",
    "files": [
        {
            "fileName": "File 2.png",
            "status": "processed",
            "result": {
                "last_job_position": "Full-Stack Developer",
                "name": "John",
                "phone_number": "000 000 000",
                "surname": "Smith",
                "years_of_experience": "6"
            },
            "url": "fileUrl"
        },
        ...
    ]
}

Last updated