curl --request GET \
--url https://api.example.com/v2/accounts/{account_id}/balance \
--header 'x-api-key: <api-key>'import requests
url = "https://api.example.com/v2/accounts/{account_id}/balance"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.example.com/v2/accounts/{account_id}/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v2/accounts/{account_id}/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v2/accounts/{account_id}/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v2/accounts/{account_id}/balance")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v2/accounts/{account_id}/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"account_id": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
"metric_id": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
"currency": "usd",
"grant_total": "1000",
"usage_total": "275.5",
"balance": "724.5"
}"<string>""Invalid API key""<string>""not found""<string>""rate limit exceeded""<string>"Retrieve an account balance for a usage source.
Returns active, effective, non-expired grants for the requested metric or currency minus corrected all-time usage for that source.
curl --request GET \
--url https://api.example.com/v2/accounts/{account_id}/balance \
--header 'x-api-key: <api-key>'import requests
url = "https://api.example.com/v2/accounts/{account_id}/balance"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.example.com/v2/accounts/{account_id}/balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/v2/accounts/{account_id}/balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/v2/accounts/{account_id}/balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/v2/accounts/{account_id}/balance")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v2/accounts/{account_id}/balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"account_id": "account_0194f4e3a2b77c6aa91c4f6b4db2a980",
"metric_id": "metric_0194f4e3a2b77c6aa91c4f6b4db2a980",
"currency": "usd",
"grant_total": "1000",
"usage_total": "275.5",
"balance": "724.5"
}"<string>""Invalid API key""<string>""not found""<string>""rate limit exceeded""<string>"Authorizations
LedgerUp API Key.
Path Parameters
Resource identifier. LedgerUp account identifier.
^account_[0-9a-f]{32}$"account_0194f4e3a2b77c6aa91c4f6b4db2a980"
Query Parameters
Metric whose usage is subtracted from the account grants. Exactly one of metric_id or currency is required. LedgerUp metric identifier.
^metric_[0-9a-f]{32}$"metric_0194f4e3a2b77c6aa91c4f6b4db2a980"
Currency whose usage is subtracted from currency grants. Exactly one of metric_id or currency is required.
^[A-Za-z]{3}$"usd"
Response
Account balance for the requested metric or currency.
LedgerUp account identifier.
^account_[0-9a-f]{32}$"account_0194f4e3a2b77c6aa91c4f6b4db2a980"
LedgerUp metric identifier. Null for a currency balance.
^metric_[0-9a-f]{32}$"metric_0194f4e3a2b77c6aa91c4f6b4db2a980"
Lowercase currency code. Null for a metric balance.
^[a-z]{3}$"usd"
Sum of all grants for the account, serialized as a string.
^-?\d+(\.\d+)?$"1000"
Sum of corrected usage events for the metric, serialized as a string.
^-?\d+(\.\d+)?$"275.5"
grant_total minus usage_total, serialized as a string.
^-?\d+(\.\d+)?$"724.5"