API Integration

Integrate our services into your applications using our REST API.

Get Started

To use our API, you need a Secret Key. You can find your Secret Key in your account settings after logging in.

Authentication

All API requests require authentication using your Secret Key. Include it in the Authorization header:

Authorization: Bearer your_secret_key_here
Security: Keep your Secret Key secure and never expose it in client-side code.
Base URL

The API base URL for your environment:

http://saskaitusuvedimas.lt/api/v1
Get document list
GET /api/v1/documents

A GET method that fetches the details of uploaded documents from saskaitusuvedimas.lt. The results can be filtered and paginated using specific query parameters.

Example Request
GET /api/v1/documents?page=0&limit=50
Query Parameters
  • status (optional): Status filter conditions:
    • 0 - Pending
    • 1 - Processing
    • 2 - Processed
    • 3 - Failed
  • externalId (optional): Filter by external ID
  • page (optional): The page number for pagination (0-based, default: 0)
  • limit (optional): Page size (default: 50, max: 100)
Responses
  • 200 Success: Returns a paginated list of uploaded document details.
  • 401 Unauthorized: Invalid or missing API key.
import requests

url = "http://saskaitusuvedimas.lt/api/v1/documents"

querystring = {
    "status": "2",
    "page": "0",
    "limit": "50"
}
# Note: externalId parameter is optional and can be omitted

headers = {
    "Authorization": "Bearer your_secret_key_here"
}

response = requests.get(url, headers=headers, params=querystring)
response.raise_for_status()

print(response.json())
curl -X GET "http://saskaitusuvedimas.lt/api/v1/documents?status=2&page=0&limit=50" \
                                                  -H "Authorization: Bearer your_secret_key_here"
using System;
using System.Net.Http;
using System.Threading.Tasks;

public class Program
{
    private static readonly HttpClient client = new HttpClient();

    public static void Main(string[] args)
    {
        GetDocumentList().Wait();
    }

    private static async Task GetDocumentList()
    {
        try
        {
            client.DefaultRequestHeaders.Authorization = 
                new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "your_secret_key_here");

            var response = await client.GetAsync("http://saskaitusuvedimas.lt/api/v1/documents?status=2&page=0&limit=50");
            response.EnsureSuccessStatusCode();

            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine($"Error: {e.Message}");
        }
    }
}
// Node.js 18+ (built-in fetch)
// For older Node.js versions, install: npm install node-fetch

const url = 'http://saskaitusuvedimas.lt/api/v1/documents?status=2&page=0&limit=50';
const options = {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer your_secret_key_here'
  }
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
Retrieve document details
GET /api/v1/documents/{id}

A GET method that retrieves the details of a specific document from saskaitusuvedimas.lt using its document ID.

Example Request
GET /api/v1/documents/abc123
Path Parameters
  • id: The document ID (string).
Responses
  • 200 Success: Returns the details of the requested document.
  • 404 Not Found: The requested document is not found.
  • 401 Unauthorized: Invalid or missing API key.
import requests

document_id = "abc123"
url = "http://saskaitusuvedimas.lt/api/v1/documents/" + document_id

headers = {
    "Authorization": "Bearer your_secret_key_here"
}

response = requests.get(url, headers=headers)
response.raise_for_status()

print(response.json())
curl -X GET "http://saskaitusuvedimas.lt/api/v1/documents/abc123" \
      -H "Authorization: Bearer your_secret_key_here"
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    private static readonly HttpClient client = new HttpClient();

    static void Main(string[] args)
    {
        GetDocumentDetails("abc123").Wait();
    }

    private static async Task GetDocumentDetails(string id)
    {
        try
        {
            client.DefaultRequestHeaders.Authorization = 
                new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "your_secret_key_here");

            var response = await client.GetAsync("http://saskaitusuvedimas.lt/api/v1/documents/" + id);
            response.EnsureSuccessStatusCode();

            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine($"Error: {e.Message}");
        }
    }
}
// Node.js 18+ (built-in fetch)
// For older Node.js versions, install: npm install node-fetch

const documentId = 'abc123';
const url = `http://saskaitusuvedimas.lt/api/v1/documents/${documentId}`;
const options = {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer your_secret_key_here'
  }
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
Enqueue a document for parsing using an external URL
POST /api/v1/documents/queue/url

A POST method that enqueues a document for parsing fields and tables using an external link. The document will be downloaded from the provided URL and processed.

Example Request
POST /api/v1/documents/queue/url
Request Body
{
  "url": "https://example.com/invoice.pdf",
  "externalId": "optional-external-id"
}
Request Parameters
  • url (required): The absolute URL of the document to download and parse. Must be a valid HTTP/HTTPS URL.
  • externalId (optional): External identifier for tracking purposes.
Responses
  • 200 OK: The document was enqueued successfully.
  • 400 Bad Request: Invalid URL or request format.
  • 401 Unauthorized: Invalid or missing API key.
Supported file types: PDF, JPG, JPEG, PNG, WEBP (Max size: 10MB)
import requests
import json

url = "http://saskaitusuvedimas.lt/api/v1/documents/queue/url"

headers = {
    "Authorization": "Bearer your_secret_key_here",
    "Content-Type": "application/json"
}

payload = {
    "url": "https://example.com/invoice.pdf",
    "externalId": "optional-external-id"
}

response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()

print(response.json())
curl -X POST "http://saskaitusuvedimas.lt/api/v1/documents/queue/url" \
      -H "Authorization: Bearer your_secret_key_here" \
      -H "Content-Type: application/json" \
      -d '{
        "url": "https://example.com/invoice.pdf",
        "externalId": "optional-external-id"
      }'
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    private static readonly HttpClient client = new HttpClient();

    static void Main(string[] args)
    {
        EnqueueDocumentFromUrl().Wait();
    }

    private static async Task EnqueueDocumentFromUrl()
    {
        try
        {
            client.DefaultRequestHeaders.Authorization = 
                new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "your_secret_key_here");

            var payload = new
            {
                url = "https://example.com/invoice.pdf",
                externalId = "optional-external-id"
            };

            var json = JsonSerializer.Serialize(payload);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await client.PostAsync("http://saskaitusuvedimas.lt/api/v1/documents/queue/url", content);
            response.EnsureSuccessStatusCode();

            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine($"Error: {e.Message}");
        }
    }
}
// Node.js 18+ (built-in fetch)
// For older Node.js versions, install: npm install node-fetch

const url = 'http://saskaitusuvedimas.lt/api/v1/documents/queue/url';
const options = {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_secret_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    url: 'https://example.com/invoice.pdf',
    externalId: 'optional-external-id'
  })
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
Enqueue a document for parsing using base64 encoded data
POST /api/v1/documents/queue/base64

A POST method that enqueues a document for parsing fields and tables using a base64 encoded binary representation. The document is identified by its filename.

Example Request
POST /api/v1/documents/queue/base64
Request Body
{
  "data": "base64-encoded-file-content",
  "filename": "invoice.pdf",
  "externalId": "optional-external-id"
}
Request Parameters
  • data (required): The base64 encoded binary representation of the document.
  • filename (optional): The identification of the file (filename). If not provided, defaults to document.pdf.
  • externalId (optional): External identifier for tracking purposes.
Responses
  • 201 Created: The document is successfully enqueued for parsing.
  • 400 Bad Request: Invalid base64 data or file type.
  • 401 Unauthorized: Invalid or missing API key.
Supported file types: PDF, JPG, JPEG, PNG, WEBP (Max size: 10MB)
import requests
import base64

# Read file and encode to base64
with open('invoice.pdf', 'rb') as f:
    file_data = base64.b64encode(f.read()).decode('utf-8')

url = "http://saskaitusuvedimas.lt/api/v1/documents/queue/base64"

headers = {
    "Authorization": "Bearer your_secret_key_here",
    "Content-Type": "application/json"
}

payload = {
    "data": file_data,
    "filename": "invoice.pdf",
    "externalId": "optional-external-id"
}

response = requests.post(url, headers=headers, json=payload)
response.raise_for_status()

print(response.json())
# First, encode file to base64
# Linux/Mac:
BASE64_DATA=$(base64 invoice.pdf)
# Windows PowerShell:
# $BASE64_DATA = [Convert]::ToBase64String([IO.File]::ReadAllBytes("invoice.pdf"))

curl -X POST "http://saskaitusuvedimas.lt/api/v1/documents/queue/base64" \
  -H "Authorization: Bearer your_secret_key_here" \
  -H "Content-Type: application/json" \
  -d "{
    \"data\": \"$BASE64_DATA\",
    \"filename\": \"invoice.pdf\",
    \"externalId\": \"optional-external-id\"
  }"
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    private static readonly HttpClient client = new HttpClient();

    static void Main(string[] args)
    {
        EnqueueDocumentFromBase64().Wait();
    }

    private static async Task EnqueueDocumentFromBase64()
    {
        try
        {
            client.DefaultRequestHeaders.Authorization = 
                new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "your_secret_key_here");

            // Read file and encode to base64
            byte[] fileBytes = File.ReadAllBytes("invoice.pdf");
            string base64Data = Convert.ToBase64String(fileBytes);

            var payload = new
            {
                data = base64Data,
                filename = "invoice.pdf",
                externalId = "optional-external-id"
            };

            var json = JsonSerializer.Serialize(payload);
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            var response = await client.PostAsync("http://saskaitusuvedimas.lt/api/v1/documents/queue/base64", content);
            response.EnsureSuccessStatusCode();

            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
        catch (HttpRequestException e)
        {
            Console.WriteLine($"Error: {e.Message}");
        }
    }
}
const fs = require('fs');
// Node.js 18+ (built-in fetch)
// For older Node.js versions, install: npm install node-fetch

// Read file and encode to base64
const fileBuffer = fs.readFileSync('invoice.pdf');
const base64Data = fileBuffer.toString('base64');

const url = 'http://saskaitusuvedimas.lt/api/v1/documents/queue/base64';
const options = {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer your_secret_key_here',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    data: base64Data,
    filename: 'invoice.pdf',
    externalId: 'optional-external-id'
  })
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
HTTP Status Codes
Code Description
200 Success
201 Created (document queued successfully)
400 Bad Request (invalid parameters or data)
401 Unauthorized (invalid or missing API key)
404 Not Found (document not found)
500 Internal Server Error
Error Response Format

When an error occurs, the API returns a JSON object with an error message:

{
  "error": "Error message description"
}

Each response comes with a schema of the resulting JSON for added comprehension. Each POST request's body must include queried parameters.