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
  • Postman Collection
  • Server URL
  • Headers
  • Body
  • Body Example
  • Code Example
  • Responses

Was this helpful?

  1. Data Extraction - API
  2. API Endpoints - Data Extraction

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"
}
Previous1. Create extractionNext3. Update extraction

Last updated 11 months ago

Was this helpful?

đŸ’ģ