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/v1Headers
Content-Type
application/json
Authorization
Bearer <token>
Body
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
In case a file is linked to an extraction template, the response will also include an extraction object with:
extractionId→ the ID of the created extraction jobbatchId→ the batch in which the file was processedfileId→ the ID of the file that was uploaded and processed in the data extraction module
{
"status": "success",
"classificationId": "classificationId",
"batchId": "batchId",
"files": [
{
"fileId": "fileId1",
"fileName": "File 1.pdf",
"status": "processed",
"result": {
"confidence": 0.9,
"documentType": "invoice"
},
"url": "fileUrl"
},
{
"fileId": "fileId1",
"fileName": "File 2.pdf",
"status": "processed",
"result": {
"confidence": 0.95,
"documentType": "resume"
},
"extraction": {
"extractionId": "extractionId",
"batchId": "batchId",
"fileId": "fileId"
},
"url": "fileUrl"
},
{
"fileId": "fileId2",
"fileName": "File 3.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"
}Last updated
Was this helpful?