Check your balance
Balance Endpoint
Get the value of your account balance, in cents.
https://sandbox.tickpay.com/api/v1/wallets/balance
Request
To access this endpoint, you need to provide a valid access token in the Authorization header.
- cURL
- C#
- JavaScript
- Python
- Java
- PHP
Use the following cURL command to retrieve the wallet balance:
curl -X 'GET' \
'https://sandbox.tickpay.com/api/v1/wallets/balance' \
-H 'accept: application/json' \
-H 'Authorization: Bearer your_access_token'
Use the following csharp command to retrieve the wallet balance:
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiUrl = "https://sandbox.tickpay.com/api/v1/wallets/balance";
string token = "your_access_token";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("accept", "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
HttpResponseMessage response = await client.GetAsync(apiUrl);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}");
}
}
}
}
Use the following javascript command to retrieve the wallet balance:
const url = 'https://sandbox.tickpay.com/api/v1/wallets/balance';
const headers = {
'accept': 'application/json',
'Authorization': 'Bearer your_access_token'
};
fetch(url, {
method: 'GET',
headers: headers
})
.then(response => response.json())
.then(data => {
console.log('Server Response:', data);
})
.catch(error => {
console.error('Request Error:', error);
});
Use the following python command to retrieve the wallet balance:
import requests
url = 'https://sandbox.tickpay.com/api/v1/wallets/balance'
headers = {
'accept': 'application/json',
'Authorization': 'Bearer your_access_token'
}
response = requests.get(url, headers=headers)
print(response.json())
Use the following java command to retrieve the wallet balance:
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;
public class Example {
public static void main(String[] args) {
HttpClient httpClient = HttpClient.newHttpClient();
String url = "https://sandbox.tickpay.com/api/v1/wallets/balance";
Map<String, String> headers = Map.of(
"accept", "application/json",
"Authorization", "Bearer your_access_token"
);
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.headers(headers.entrySet().stream()
.flatMap(e -> Map.entry(e.getKey(), e.getValue()).stream())
.toArray(String[]::new))
.GET()
.build();
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Use the following php command to retrieve the wallet balance:
<?php
$apiUrl = "https://sandbox.tickpay.com/api/v1/wallets/balance";
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'accept: application/json',
'Authorization: Bearer your_access_token'
]);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
}
curl_close($ch);
echo $result;
?>
Response
The response will contain a data object, along with additional information:
{
"data": {
"value": 6200
},
"messageError": null,
"success": true
}
Response Properties
| Parameter | Description | Default Value |
|---|---|---|
messageError | Error message. | null |
success | Indicates whether the request was successful. | false |
data Properties | ||
value | The specific value in the response, representing cents. | 0 |