2. View extraction
POST
/viewExtraction
This endpoint retrieves the details of an extraction process previously defined in the system. By submitting the unique extractionId
, you can obtain information such as the extraction name, language, options set, and the fields that are being extracted. This is useful for verifying the setup of your extraction template or for debugging purposes.
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
Unique identifier for the extraction.
Body Example
{
"extractionId": "extractionId"
}
Code Example
const axios = require('axios');
/**
* Retrieves details of an extraction process by its unique extractionId.
*
* @param {string} token - The authorization token to access the API.
* @param {string} extractionId - The unique identifier for the extraction.
* @returns {Promise<Object>} The promise that resolves to the extraction details.
*/
async function viewExtraction(token, extractionId) {
const url = "https://api.extracta.ai/api/v1/viewExtraction";
try {
const response = await axios.post(url, {
extractionId: extractionId
}, {
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';
try {
const extractionDetails = await viewExtraction(token, extractionId);
console.log("Extraction Details:", extractionDetails);
} catch (error) {
console.error("Failed to retrieve extraction details:", error);
}
}
main();
import requests
def view_extraction(token, extraction_id):
"""
Retrieves details of an extraction process by its unique extractionId.
:param token: The authorization token to access the API.
:param extraction_id: The unique identifier for the extraction.
:return: The extraction details as a dictionary.
"""
url = "https://api.extracta.ai/api/v1/viewExtraction"
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {token}'
}
payload = {
'extractionId': extraction_id
}
try:
response = requests.post(url, json=payload, 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 both HTTPError and other request-related errors
print(f"Failed to retrieve extraction details: {e}")
return None
# Example usage
if __name__ == "__main__":
token = 'apiKey'
extraction_id = 'extractionId'
extraction_details = view_extraction(token, extraction_id)
if extraction_details is not None:
print("Extraction Details:", extraction_details)
<?php
/**
* Retrieves details of an extraction process by its unique extractionId.
*
* @param string $token The authorization token to access the API.
* @param string $extractionId The unique identifier for the extraction.
* @return mixed The extraction details or an error message.
*/
function viewExtraction($token, $extractionId) {
$url = 'https://api.extracta.ai/api/v1/viewExtraction';
// Initialize cURL session
$ch = curl_init($url);
// Prepare the payload
$payload = json_encode(['extractionId' => $extractionId]);
// 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 {
// Execute cURL session
$response = curl_exec($ch);
// Check for cURL errors
if (curl_errno($ch)) {
throw new Exception('Curl error: ' . curl_error($ch));
}
// return the response as a object
return json_decode($response, true);
} catch (Exception $e) {
// Handle exceptions or errors here
return 'Error: ' . $e->getMessage();
} finally {
// Always close the cURL session
curl_close($ch);
}
}
// Example usage
$token = 'apiKey';
$extractionId = 'extractionId';
try {
$extractionDetails = viewExtraction($token, $extractionId);
print_r($extractionDetails);
} catch (Exception $e) {
echo "Failed to retrieve extraction details: " . $e->getMessage();
}
?>
Responses
{
"extractionId": "extractionId",
"extractionDetails": {
"status": "has batches",
"batches": {
"33NjeFksJFZVTpLWSFSrlWkxy": {
"filesNo": 3,
"origin": "api",
"startTime": "1699370066649",
"status": "finished"
},
...
},
"name": "API CVs",
"description": "...",
"language": "English",
"options": {
"handwrittenTextRecognition": true,
"hasTable": false
},
"fields": [
{
"description": "",
"example": "",
"key": "name"
},
...
],
}
}
{
"status": "error",
"message": "Extraction does not exist",
"extractionId": "extractiondId"
}
{
"status": "error",
"message": "Could not get extraction",
"extractionId": "extractiondId"
}
Last updated