6. Get 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.

When also providing the fileId, the endpoint filters the results to only that file.

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

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

Name
Type
Required
Description

extractionId

string

true

The ID of the extraction

batchId

string

true

The ID of the batch

fileId

string

false

The ID of the file

Body Example

{
    "extractionId": "extractionId",
    "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');

/**
 * 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.
 * @param {string} [fileId] - The unique identifier for the file (optional).
 * @returns {Promise<Object>} The promise that resolves to the batch results.
 */
async function getBatchResults(token, extractionId, batchId, fileId) {
    const url = "https://api.extracta.ai/api/v1/getBatchResults";

    try {
        // Constructing the request payload
        const payload = {
            extractionId,
            batchId
        };

        // Adding fileId to the payload if provided
        if (fileId) {
            payload.fileId = fileId;
        }

        const response = await axios.post(url, payload, {
            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 = 'batchId';
    const fileId = 'optionalFileId'; // Set this to null or undefined if you don't want to include it

    try {
        const batchResults = await getBatchResults(token, extractionId, batchId, fileId);
        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