API Reference
Get Transactions
Retrieve transactions for a company
Endpoint
GET /api/v1/companies/{cvr}/transactionsDescription
Returns a paginated list of Mastercard disposition transactions for a specific company.
Authentication
Required - Include X-API-Key header
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cvr | string | Yes | 8-digit Danish CVR number |
Query Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
limit | integer | No | 50 | Number of results per page (1-100) |
after | string | No | - | Cursor for fetching the next page |
before | string | No | - | Cursor for fetching the previous page |
Request
curl -X GET "https://betalink.dev/api/v1/companies/12345678/transactions?limit=20" \
-H "X-API-Key: your-api-key"Response
Success (200 OK)
{
"data": [
{
"id": "tx_abc123def456",
"mastercardDeliveryFileId": "file_xyz789",
"recordIndex": 42,
"cvr": "12345678",
"regNumber": "1234",
"accountNumber": "0012345678",
"transferType": "BS",
"dispositionDate": "2024-06-15",
"count": 1,
"amountDkk": "1250.00",
"rawLine": "BS1234567812340012345678...",
"createdAt": "2024-06-15T08:00:00Z",
"updatedAt": "2024-06-15T08:00:00Z",
"filename": "MC_DISP_20240615_001.txt",
"processedAt": "2024-06-15T08:30:00Z"
}
],
"meta": {
"total": 847,
"limit": 20,
"hasMore": true
},
"_links": {
"self": "/api/v1/companies/12345678/transactions?limit=20",
"next": "/api/v1/companies/12345678/transactions?limit=20&after=tx_abc123def456",
"prev": null
}
}Transaction Object
| Field | Type | Description |
|---|---|---|
id | string | Unique transaction identifier |
mastercardDeliveryFileId | string | ID of the source delivery file |
recordIndex | number | Position in the delivery file |
cvr | string | Company CVR number |
regNumber | string | Bank registration number |
accountNumber | string | Bank account number |
transferType | string | Transaction transfer type |
dispositionDate | string | Date of disposition (YYYY-MM-DD) |
count | number | Transaction count |
amountDkk | string | Amount in DKK (decimal string) |
rawLine | string | Raw line from the PBS file |
createdAt | string | null | ISO 8601 creation timestamp |
updatedAt | string | null | ISO 8601 last update timestamp |
filename | string | Source file name |
processedAt | string | null | When the file was processed |
Error Responses
401 Unauthorized
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}404 Not Found
{
"error": {
"code": "COMPANY_NOT_FOUND",
"message": "No company found with CVR 12345678"
}
}Code Example
import { createBetalinkClient } from "@betalink/api-client";
const client = createBetalinkClient({
baseUrl: "https://betalink.dev/api",
apiKey: "your-api-key",
});
// Get transactions for a company
const response = await client.getCompanyTransactions("12345678", {
limit: 50,
});
console.log(`Total transactions: ${response.meta.total}`);
for (const tx of response.data) {
console.log(`${tx.dispositionDate}: ${tx.amountDkk} DKK`);
}Fetching All Transactions
async function getAllTransactions(cvr: string) {
const transactions = [];
let after: string | undefined;
do {
const response = await client.getCompanyTransactions(cvr, {
limit: 100,
after,
});
transactions.push(...response.data);
if (response.meta.hasMore && response.data.length > 0) {
after = response.data[response.data.length - 1].id;
} else {
break;
}
} while (true);
return transactions;
}
const allTx = await getAllTransactions("12345678");
console.log(`Fetched ${allTx.length} transactions`);Calculating Totals
const response = await client.getCompanyTransactions("12345678");
const total = response.data.reduce(
(sum, tx) => sum + parseFloat(tx.amountDkk),
0
);
console.log(`Total amount: ${total.toFixed(2)} DKK`);Filtering by Date
While the API doesn't support date filtering directly, you can filter client-side:
const response = await client.getCompanyTransactions("12345678", {
limit: 100,
});
const june2024 = response.data.filter((tx) => {
const date = new Date(tx.dispositionDate);
return date.getFullYear() === 2024 && date.getMonth() === 5; // June
});
console.log(`June 2024 transactions: ${june2024.length}`);