User Transaction History
Endpoint
https://api.betatel.com/api/billing/me/transactions
Method: POST
Description: Retrieve transaction history for a specific user.
Request Headers
The request must include an Authorization header with a valid API key for authentication:
Header | Value | Required | Description |
---|---|---|---|
x-api-key | {{x-api-key}} | Yes | The authentication API key to verify the user's identity |
Request Body
Your request should contain the following structure:
{
"filter": {
"serviceId": "otp-call",
"datetime": {
"from": "2025-03-25T09:00:00Z",
"to": "2025-03-25T09:12:00Z"
},
"type": "CREDIT",
"currency": "EUR"
},
"rowsPerPage": 20,
"page": 1
}
Request Parameters
Param | Value | Type | Required | Description |
---|---|---|---|---|
datetime | - | Object | No | Filter transactions for specific date (ISO 8601), for range use from:,to: |
serviceId | otp-call | String | No | Filter by service ID |
currency | EUR | String | No | Filter by currency code |
type | CREDIT | String | No | Filter by transaction type |
page | 1 | Int | No | Page number (default: 1) |
rowsPerPage | 20 | Int | No | Records per page (default: 20) |
Let’s Dive Into the Code!
Choose your preferred programming language and use the provided examples to integrate the user transaction history.
- cUrl
- Python
- Node.js
- PHP
- Java
- C#
Example - cURL
curl --location 'https://api.betatel.com/api/billing/me/transactions' \
--header 'Content-Type: application/json' \
--header 'x-api-key: C8FdQrQKxXiLvUtEoyLobJopZwZhalPhdoDr9qVxACBI' \
--data '{
"filter": {
"serviceId": "otp-call",
"datetime": { "from": "2025-03-25T09:00:00Z", "to": "2025-03-25T10:00:00Z" },
"type": "CREDIT",
"currency": "EUR",
"userId": "67a1cfd3e547d3bea4694f51"
},
"rowsPerPage": 20,
"page": 1
}'
Example - Python
import http.client
import json
conn = http.client.HTTPSConnection("api.betatel.com")
payload = json.dumps({
"filter": {
"serviceId": "otp-call",
"datetime": {
"from": "2025-03-25T09:00:00Z",
"to": "2025-03-25T10:00:00Z"
},
"type": "CREDIT",
"currency": "EUR",
"userId": "67a1cfd3e547d3bea4694f51"
},
"rowsPerPage": 20,
"page": 1
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'C8FdQrQKxXiLvUtEoyLobJopZwZhalPhdoDr9qVxACBI'
}
conn.request("POST", "/api/billing/me/transactions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Example - Node.js
const axios = require('axios');
let data = JSON.stringify({
"filter": {
"serviceId": "otp-call",
"datetime": {
"from": "2025-03-25T09:00:00Z",
"to": "2025-03-25T10:00:00Z"
},
"type": "CREDIT",
"currency": "EUR",
"userId": "67a1cfd3e547d3bea4694f51"
},
"rowsPerPage": 20,
"page": 1
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api.betatel.com/api/billing/me/transactions',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'C8FdQrQKxXiLvUtEoyLobJopZwZhalPhdoDr9qVxACBI'
},
data : data
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Example - PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.betatel.com/api/billing/me/transactions',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"filter": {
"serviceId": "otp-call",
"datetime": { "from": "2025-03-25T09:00:00Z", "to": "2025-03-25T10:00:00Z" },
"type": "CREDIT",
"currency": "EUR",
"userId": "67a1cfd3e547d3bea4694f51"
},
"rowsPerPage": 20,
"page": 1
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'x-api-key: C8FdQrQKxXiLvUtEoyLobJopZwZhalPhdoDr9qVxACBI'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Example - Java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api.betatel.com/api/billing/me/transactions")
.header("Content-Type", "application/json")
.header("x-api-key", "C8FdQrQKxXiLvUtEoyLobJopZwZhalPhdoDr9qVxACBI")
.body("{\n \"filter\": {\n \"serviceId\": \"otp-call\",\n \"datetime\": { \"from\": \"2025-03-25T09:00:00Z\", \"to\": \"2025-03-25T10:00:00Z\" },\n \"type\": \"CREDIT\",\n \"currency\": \"EUR\",\n \"userId\": \"67a1cfd3e547d3bea4694f51\"\n },\n \"rowsPerPage\": 20,\n \"page\": 1\n}")
.asString();
Example - C#
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.betatel.com/api/billing/me/transactions");
request.Headers.Add("x-api-key", "C8FdQrQKxXiLvUtEoyLobJopZwZhalPhdoDr9qVxACBI");
var content = new StringContent("{\n \"filter\": {\n \"serviceId\": \"otp-call\",\n \"datetime\": { \"from\": \"2025-03-25T09:00:00Z\", \"to\": \"2025-03-25T10:00:00Z\" },\n \"type\": \"CREDIT\",\n \"currency\": \"EUR\",\n \"userId\": \"67a1cfd3e547d3bea4694f51\"\n },\n \"rowsPerPage\": 20,\n \"page\": 1\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Response
JSON Schema:
{
"filter": {
"serviceId": "otp-call",
"datetime": {
"from": "2025-03-25T09:00:00Z",
"to": "2025-03-25T09:12:00Z"
},
"type": "CREDIT",
"currency": "EUR",
"userId": "67a1cfd3e547d3bea4694f51"
},
"page": 1,
"rowsPerPage": 20,
"list": [
{
"_id": "67e272f3296990d38bead330",
"transaction_id": "fjdkfjdk7438473843re",
"correlation_id": "qwertzui1234567898765432345",
"user_id": "67a1cfd3e547d3bea4694f51",
"service_id": "otp-call",
"type": "CREDIT",
"description": "New credit",
"datetime": "2025-03-25T09:10:02.613Z",
"unit_price": 20,
"quantity": 1,
"value": 20,
"currency": "EUR",
"balance_after": 20,
"__v": 0
}
],
"total": 1,
"totalPages": 1,
"hasPreviousPage": false,
"hasNextPage": false
}
Field | Type | Description |
---|---|---|
filter | object | The filters applied to the transaction history query. |
- serviceId | string | The identifier for the service (e.g., "otp-call"). |
- datetime | object | The date and time range for filtering transactions. |
-- from | string | The start of the datetime range (e.g., "2025-03-25T09:00:00Z"). |
-- to | string | The end of the datetime range (e.g., "2025-03-25T09:12:00Z"). |
- type | string | The type of transaction (e.g., "CREDIT"). |
- currency | string | The currency for the transactions (e.g., "EUR"). |
- userId | string | The unique identifier for the user (e.g., "67a1cfd3e547d3bea4694f51"). |
page | number | The current page of results (e.g., 1). |
rowsPerPage | number | The number of rows per page (e.g., 20). |
list | array | A list of transactions matching the filters. |
- _id | string | The unique identifier for the transaction (e.g., "67e272f3296990d38bead330"). |
- transaction_id | string | The unique identifier for the transaction (e.g., "fjdkfjdk7438473843re"). |
- correlation_id | string | A unique identifier for the authorization request (e.g., "qwertzui1234567898765432345"). |
- user_id | string | The unique identifier for the user (e.g., "67a1cfd3e547d3bea4694f51"). |
- service_id | string | The identifier for the service associated with the transaction (e.g., "otp-call"). |
- type | string | The type of transaction (e.g., "CREDIT"). |
- description | string | A description of the transaction (e.g., "New credit"). |
- datetime | string | The timestamp of when the transaction occurred (e.g., "2025-03-25T09:10:02.613Z"). |
- unit_price | number | The price per unit for the service (e.g., 20). |
- quantity | number | The quantity of the service used (e.g., 1). |
- value | number | The total value of the transaction (e.g., 20). |
- currency | string | The currency in which the transaction is represented (e.g., "EUR"). |
- balance_after | number | The user's balance after the transaction (e.g., 20). |
total | number | The total number of transactions matching the filters (e.g., 1). |
totalPages | number | The total number of pages of results (e.g., 1). |
hasPreviousPage | boolean | Indicates if there is a previous page of results (e.g., false). |
hasNextPage | boolean | Indicates if there is a next page of results (e.g., false). |