Ten dokument zawiera szczegółowe informacje o dostępnych endpointach API do przetwarzania faktur, formatach żądań i odpowiedzi oraz przykłady użycia.
Uwaga: W razie problemów z API, zapoznaj się z przewodnikiem rozwiązywania problemów.
All API endpoints are relative to the base URL:
http://localhost:8088 # or your configured host:port
Currently, the API does not require authentication for local development. For production use, consider implementing API key authentication.
Check if the API is running.
Endpoint: GET /health
Response:
{
"status": "ok"
}
Process an invoice image or PDF and extract structured data.
Endpoint: POST /process
Content-Type: multipart/form-data
Request Parameters:
file
(required): The invoice file (image or PDF)extract_tables
(optional, boolean): Whether to extract tables (default: true
)language
(optional, string): Language code (e.g., ‘en’, ‘de’, ‘et’)Example Request:
curl -X POST http://localhost:8088/process \
-F "file=@/path/to/invoice.pdf" \
-F "extract_tables=true" \
-F "language=en"
Success Response (200 OK):
{
"status": "success",
"data": {
"vendor_name": "Example Corp",
"invoice_number": "INV-2023-001",
"invoice_date": "2023-01-15",
"due_date": "2023-02-14",
"total_amount": 1234.56,
"currency": "EUR",
"line_items": [
{
"description": "Product A",
"quantity": 2,
"unit_price": 500.00,
"total": 1000.00
}
],
"tables": [
{
"header": ["Description", "Qty", "Price", "Total"],
"rows": [
["Product A", "2", "500.00", "1000.00"]
]
}
],
"metadata": {
"processing_time": 1.23,
"model": "facebook/opt-125m",
"ocr_engine": "easyocr"
}
}
}
Error Response (400 Bad Request):
{
"status": "error",
"error": {
"code": "invalid_file",
"message": "Unsupported file type. Please upload a PDF or image file."
}
}
Process raw invoice text and extract structured data.
Endpoint: POST /process/text
Content-Type: application/json
Request Body:
{
"text": "INVOICE\nVendor: Example Corp\nInvoice #: INV-2023-001\n...",
"language": "en"
}
Example Request:
curl -X POST http://localhost:8088/process/text \
-H "Content-Type: application/json" \
-d '{"text":"INVOICE\\nVendor: Example Corp\\n...", "language":"en"}'
Response:
Same structure as the /process
endpoint.
By default, the API is limited to 60 requests per minute per IP address. If exceeded, you’ll receive a 429 Too Many Requests response.
All error responses follow this format:
{
"status": "error",
"error": {
"code": "error_code",
"message": "Human-readable error message"
}
}
Common error codes:
invalid_file
: Unsupported or corrupted filefile_too_large
: File exceeds maximum allowed size (default: 50MB)invalid_request
: Missing or invalid parametersprocessing_error
: Error during invoice processingrate_limit_exceeded
: Too many requestsYou can test the API using the built-in Swagger UI:
http://localhost:8088/docs
in your browserimport requests
def process_invoice(api_url, file_path, language='en'):
with open(file_path, 'rb') as f:
files = {'file': f}
data = {'language': language}
response = requests.post(f"{api_url}/process", files=files, data=data)
return response.json()
# Usage
result = process_invoice('http://localhost:8088', 'invoice.pdf')
print(result)
API versioning is not yet implemented. All endpoints are currently under /v1/
.
For support, please open an issue on our GitHub repository.