Endpoint Description
The/process_excel endpoint accepts an Excel file containing invoice data and transforms each row into a structured JSON document following the Venezuelan electronic invoice standard. The API returns a ZIP file containing all generated invoices organized into batches.
HTTP Method and Path
Request Parameters
Excel file (.xlsx or .xls) containing invoice data. The file should include columns for customer information, invoice details, amounts, and dates.Expected columns:
- Correlativo (Invoice number)
- Fecha Emision (Issue date)
- Fecha Vencimiento (Due date)
- Fecha Pago (Payment date)
- Cliente (Customer name)
- Documento (Document type)
- DNI/C.I./C.C./IFE (ID number)
- Dirección (Address)
- Telefono (Phone)
- Correo (Email)
- Plan (Service description)
- Total (Total in USD)
- bolivares (Total in Bolivares)
- bolivares sin iva (Bolivares without VAT)
- precio sin iva (USD without VAT)
- Tasa (Exchange rate)
- Forma de Pago (Payment method)
- ID Servicio (Service ID)
Content-Type
The request must use
multipart/form-data encoding to upload the Excel file.Request Examples
Response Format
Content-Type:application/zip
Headers:
Response Structure
ZIP File Organization
The returned ZIP file contains a hierarchical structure (main.py:259-271):- Date format:
YYYYMMDD(e.g., 20260304 for March 4, 2026) - Batch folders: Invoices are grouped in batches of 100
- Batch naming:
J408185431-YYYYMMDD-XXXwhere XXX is the batch number (001, 002, etc.) - File naming: Invoice files are named with zero-padded correlative numbers (0000001.json, 0000002.json, etc.)
JSON Invoice Structure
Each JSON file contains a complete electronic invoice document (main.py:94-249):Complete JSON Schema Details
Complete JSON Schema Details
Key Features:
- Dual Currency Support: Both Bolivares (BSD) and US Dollars (USD) with automatic exchange rate conversion
- VAT Calculation: Automatic IVA (16%) calculation on all amounts (main.py:83-84)
- Amount to Words: Monetary amounts converted to Spanish words (main.py:36-71)
- Usage Statistics: Random navigation statistics for service tracking (main.py:86-92)
- Batch Processing: Each invoice marked with
"EsLote": truefor batch processing
- IdentificacionDocumento: Invoice metadata, dates, and transaction ID
- Comprador: Customer information (ID, name, address, contact)
- Totales: Financial totals in Bolivares with tax breakdown
- TotalesOtraMoneda: Financial totals in USD
- DetallesItems: Line items (services/products)
- InfoAdicional: Additional service contract and usage data
Status Codes
Request processed successfully. Returns a ZIP file containing all generated invoices.
Invalid request. The file parameter is missing or the uploaded file is not a valid Excel file.Example Error Response:
Server encountered an error processing the Excel file. This may occur due to:
- Malformed Excel file structure
- Missing required columns
- Invalid data types in cells
- Memory issues with large files
Error Responses
Missing File Parameter
Invalid File Format
If the uploaded file cannot be parsed as Excel:Missing Required Columns
If the Excel file is missing required columns, pandas will raise a KeyError during processing:Implementation Details
The endpoint implementation (main.py:252-278):Processing Flow
- File Upload: Receives Excel file via multipart/form-data (line 253)
- Parse Excel: Reads file into pandas DataFrame, fills NA values with empty strings (line 255)
- Generate Date: Creates timestamp for folder naming (line 257)
- Create ZIP: Initializes in-memory ZIP archive (line 260)
- Process Rows: Iterates through each Excel row (line 262)
- Transforms row data into JSON structure via
transformar_fila() - Zero-pads correlative number to 6 digits
- Calculates batch number (100 invoices per batch)
- Generates folder and file paths
- Writes JSON to ZIP archive
- Transforms row data into JSON structure via
- Return Response: Streams ZIP file to client with appropriate headers (line 274-278)
The entire ZIP file is generated in memory using
io.BytesIO(), making it efficient for moderate file sizes but potentially memory-intensive for very large datasets.Performance Considerations
- Batch Size: Invoices are automatically split into batches of 100 to maintain organized folder structures
- Memory Usage: The entire ZIP file is built in memory. For very large Excel files (>10,000 rows), consider monitoring memory usage
- Processing Time: Scales linearly with the number of rows in the Excel file
- File Size: Generated JSON files are formatted with 4-space indentation, which increases readability but also file size
Related Resources
API Overview
View complete API documentation
Error Handling
Learn about error codes and responses