GET /v1/budgets
The budgets in effect for a month, with what was spent in each category. Spending is outgoing amounts, with transfers and split parents left out.
Auth. Send the token in the X-Ledger-Token header.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
month | query | string | optional | The month, YYYY-MM. Defaults to the current month (UTC). |
Responses
| Status | Meaning | Body |
|---|---|---|
200 | The budgets for the month. Pace is given only for the current month. | object |
400 | Request rejected | Error |
429 | Too many requests from this client address. Wait the number of seconds in Retry-After, then try again. | Error |
Example response
{
"month": "string",
"current": true,
"days_in_month": 0,
"days_elapsed": 0,
"budgets": [
{
"category": "string",
"budget_cents": 1,
"spent_cents": 0,
"remaining_cents": 0,
"over": true,
"pace_cents": 0
}
],
"unbudgeted_spent_cents": 0,
"unbudgeted": [
{
"category": "string",
"spent_cents": 1
}
],
"totals": {
"budget_cents": 0,
"spent_cents": 0,
"remaining_cents": 0
}
}
Code samples
Set KEY to your own token first.
curl
curl \
-H X-Ledger-Token:$KEY \
"https://api.sasek.org/ledger/v1/budgets"
JavaScript
const res = await fetch("https://api.sasek.org/ledger/v1/budgets", {
headers: { "X-Ledger-Token": KEY },
});
const data = await res.json();
Python
import json
import os
import urllib.request
request = urllib.request.Request(
"https://api.sasek.org/ledger/v1/budgets",
method="GET",
headers={
"X-Ledger-Token": os.environ["KEY"],
},
)
with urllib.request.urlopen(request) as response:
print(json.load(response))