GET /v1/budgets/suggestions

A suggested budget per category, the average monthly spend over the last 3 or 4 complete months, rounded up to the next dollar. Read only; nothing is saved.

Auth. Send the token in the X-Ledger-Token header.

Parameters

NameInTypeRequiredDescription
monthsquerystring: one of 3, 4optionalHow many complete months to average, 3 or 4. Defaults to 3.

Responses

StatusMeaningBody
200The suggestions. A month counts only if the ledger has a transaction in it; uncategorized spending is never suggested.object
400Request rejectedError
429Too many requests from this client address. Wait the number of seconds in Retry-After, then try again.Error

Example response

{
  "months": 0,
  "counted_months": [
    "string"
  ],
  "suggestions": [
    {
      "category": "string",
      "average_cents": 0,
      "suggested_cents": 100,
      "months_with_spend": 1
    }
  ]
}

Code samples

Set KEY to your own token first.

curl

curl \
  -H X-Ledger-Token:$KEY \
  "https://api.sasek.org/ledger/v1/budgets/suggestions"

JavaScript

const res = await fetch("https://api.sasek.org/ledger/v1/budgets/suggestions", {
  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/suggestions",
    method="GET",
    headers={
        "X-Ledger-Token": os.environ["KEY"],
    },
)
with urllib.request.urlopen(request) as response:
    print(json.load(response))