The invoices API supports page-based listing, filtering, and optional include flags for related records. This guide focuses on the read side: listing invoices, fetching a single invoice, and understanding when to include items, clients, or transactions.
curl -X GET "https://algapsa.com/api/v1/invoices?page=1&limit=25&include_client=true&include_items=true" \
-H "X-API-Key: $ALGA_API_KEY"const url = new URL('https://algapsa.com/api/v1/invoices');
url.searchParams.set('page', '1');
url.searchParams.set('limit', '25');
url.searchParams.set('include_client', 'true');
url.searchParams.set('include_items', 'true');
const response = await fetch(url.toString(), {
headers: {
'X-API-Key': process.env.ALGA_API_KEY!,
},
});
const result = await response.json();
if (!response.ok) {
throw new Error(result.error?.message ?? 'Invoice list failed');
}
console.log(result.pagination);Use the invoice ID when you need a single billing record. Add include flags only when the consuming screen actually needs them.
curl -X GET "https://algapsa.com/api/v1/invoices/$INVOICE_ID?include_transactions=true" \
-H "X-API-Key: $ALGA_API_KEY"The include flags are convenient, but the nested endpoints are still useful when you want to defer loading large item lists or payment history.
curl -X GET "https://algapsa.com/api/v1/invoices/$INVOICE_ID/items" \
-H "X-API-Key: $ALGA_API_KEY"
curl -X GET "https://algapsa.com/api/v1/invoices/$INVOICE_ID/transactions" \
-H "X-API-Key: $ALGA_API_KEY"