# Retrieve Invoice Info API

The following endpoint enables user to extract relevant invoice info (invoice number, invoice date, invoice total, invoice description) from pdf invoice file .

https://api.fatora.io/ai/retrieveInfo
curl --location --request POST $API_ENDPOINT \
--header 'Content-Type: multipart/form-data' \
-F 'invoice_file=@'$PDF_FILE_PATH'
// API Endpoint
$apiEndpoint = "https://api.fatora.io/ai/retrieveInfo";
// File to Upload
$pdfFilePath = "/path/to/your/invoice.pdf";
// Headers
$headers = [
    'Content-Type: multipart/form-data'   
];
// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $apiEndpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
    'invoice_file' => new CURLFile($pdfFilePath)
   
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

// Execute cURL session and get the response
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
    echo 'Curl error: ' . curl_error($ch);
}

// Close cURL session
curl_close($ch);

// Display the API response
echo $response;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        Task.Run(async () => await YourAsyncMethod()).Wait();            
    }

    static async Task YourAsyncMethod()
    {
        // Replace "your_invoice_file_path" with the actual file path
        string filePath = "your_invoice_file_path";
        await UploadFileAsync(filePath);
    }
    static async Task UploadFileAsync(string filePath)
    {
        try
        {
            // Create HttpClient
            using (HttpClient client = new HttpClient())
            using (MultipartFormDataContent form = new MultipartFormDataContent())
            using (FileStream fileStream = File.OpenRead(filePath))
            {
                // Append the file to the form data
                form.Add(new StreamContent(fileStream), "invoiceFile", Path.GetFileName(filePath));

                // API endpoint URL
                string apiUrl = "https://api.fatora.io/ai/retrieveInfo";

                // Send the request
                HttpResponseMessage response = await client.PostAsync(apiUrl, form);

                // Handle the response
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("File uploaded successfully");

                    // Retrieve and handle the response text
                    string responseText = await response.Content.ReadAsStringAsync();
                }
                else
                {
                    Console.WriteLine($"Error: Request failed with status: {response.StatusCode}");
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
}
{
    "status": "SUCCESS",
    "invoice": {        
        "invoice_number": "INV_123",
        "invoice_date": "01/01/2024",
        "invoice_price":"539.41",
        "line_items": "items decription of invoice"     
    }
}

Try it now: Retrieve Invoice Info API

Header Parameters

Header Value
Content-Type REQUIRED multipart/form-data

Request Parameters

Parameter Description
File REQUIRED fileThe pdf file of the invoice.

Response

Response Schema: application/json
status string the status of response.
SUCCESS
invoice object:
  • invoice_number: string the number of invoice
  • invoice_date: string the date of invoice
  • invoice_price: string the price of invoice
  • line_items: string the description items of invoice

Otherwise if there was a problem with your request, you'll receive an error response such as 400 status code, and the response will include an error object describing why this request failed.

Response Schema: application/json
status string The status of response.
error object:
  • error_code string, the naumber of error: e.g: 400, For more information
    see Response Code
  • description string, the description of error: e.g: bad request
technical-support

🛠️ Technical Support