Developer API
Write recipes
Five complete Developer API scripts that change data: recategorize a merchant, split a transaction, split the rent, tag a trip, add rows from a CSV.
This page has five complete scripts that change data through the Developer API, each as a shell script (curl and jq) and as a Python script that uses only the standard library, with the output of a real run. Like the read recipes, they take the app’s address from TAIGA_API and a token from TAIGA_TOKEN, and add /api/v1 to every path, so with TAIGA_API=https://app.taiga.finance the requests go to https://app.taiga.finance/api/v1. Each needs a token that can change data: you choose whether a token can change data when you create it in Settings, and a read-only token’s write is 403 read_only_token. The runs used a demo household’s seeded data.
How do I recategorize one merchant’s recent transactions?
Section titled “How do I recategorize one merchant’s recent transactions?”This script reads a window of recent days, keeps one merchant’s transactions that are not yet in the target category, and sends them all in one batch, each update carrying what the script read as a precondition. It needs a token that can change data, and bash with curl, jq and GNU date, or Python 3.
#!/usr/bin/env bash# Recategorize one merchant's recent transactions: read, filter, then ONE batch# whose every update carries what was read as a precondition (all or nothing).# Needs curl, jq and GNU date; a token that can change data.# Usage: ./c-recategorize-merchant.sh "Steam Games" "Shopping::Entertainment & Recreation" 120set -euo pipefail: "${TAIGA_API:?set TAIGA_API}" "${TAIGA_TOKEN:?set TAIGA_TOKEN}"merchant=$1; category=$2; days=${3:-90}from=$(date -d "-$days days" +%F); to=$(date +%F)auth=(-H "Authorization: Bearer $TAIGA_TOKEN")
# Read the window (follow next_cursor) and keep this merchant's unsplit rows not yet in the category.rows='[]'; cursor=""while :; do page=$(curl -sS --fail-with-body "${auth[@]}" \ "$TAIGA_API/api/v1/transactions?from=$from&to=$to&limit=1000${cursor:+&cursor=$cursor}") rows=$(jq -c --argjson acc "$rows" '$acc + .data' <<<"$page") cursor=$(jq -r '.next_cursor // empty' <<<"$page") [ -n "$cursor" ] || breakdonebody=$(jq -c --arg m "$merchant" --arg c "$category" ' { updates: [ .[] | select(.merchant == $m and .split_of == null and (.parent_category + "::" + .category) != $c) | { id, category: $c, expected: { parent_category, category, merchant } } ] }' <<<"$rows")n=$(jq '.updates | length' <<<"$body")echo "$n transaction(s) of $merchant to change"[ "$n" -gt 0 ] || exit 0
curl -sS -w '\nHTTP %{http_code}\n' -X POST "$TAIGA_API/api/v1/transactions/batch" "${auth[@]}" \ -H "Content-Type: application/json" -d "$body""""Recategorize one merchant's recent transactions: read, filter, then ONE batchwhose every update carries what was read as a precondition (all or nothing).
Standard library only; a token that can change data.Usage: python3 c-recategorize-merchant.py "Steam Games" "Shopping::Entertainment & Recreation" 120"""import jsonimport osimport sysimport urllib.errorimport urllib.parseimport urllib.requestfrom datetime import date, timedelta
API = os.environ["TAIGA_API"]TOKEN = os.environ["TAIGA_TOKEN"]
def call(method, path, body=None, **params): url = f"{API}/api/v1{path}" + (f"?{urllib.parse.urlencode(params)}" if params else "") data = None if body is None else json.dumps(body).encode() req = urllib.request.Request(url, data=data, method=method, headers={ "Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}) try: with urllib.request.urlopen(req) as resp: return resp.status, json.load(resp) except urllib.error.HTTPError as e: return e.code, json.load(e)
merchant, category = sys.argv[1], sys.argv[2]days = int(sys.argv[3]) if len(sys.argv) > 3 else 90params = {"from": (date.today() - timedelta(days=days)).isoformat(), "to": date.today().isoformat(), "limit": 1000}rows = []while True: status, page = call("GET", "/transactions", **params) if status != 200: sys.exit(f"HTTP {status}: {page}") rows += page["data"] if not page["next_cursor"]: break params["cursor"] = page["next_cursor"]
updates = [ {"id": t["id"], "category": category, "expected": {k: t[k] for k in ("parent_category", "category", "merchant")}} for t in rows if t["merchant"] == merchant and t["split_of"] is None and f"{t['parent_category']}::{t['category']}" != category]print(f"{len(updates)} transaction(s) of {merchant} to change")if updates: status, result = call("POST", "/transactions/batch", {"updates": updates}) print(status, json.dumps(result))The shell run moved eight Steam Games transactions and then ran again with nothing left to change. The Python run did the same for four Netflix transactions.
$ ./c-recategorize-merchant.sh "Steam Games" "Shopping::Entertainment & Recreation" 1208 transaction(s) of Steam Games to change{"data":[{"id":"1612479","changed":true},{"id":"1612480","changed":true},{"id":"1612521","changed":true},{"id":"1612541","changed":true},{"id":"1612582","changed":true},{"id":"1612615","changed":true},{"id":"1612760","changed":true},{"id":"1612761","changed":true}],"changes":8}HTTP 200
$ ./c-recategorize-merchant.sh "Steam Games" "Shopping::Entertainment & Recreation" 120 # run again: nothing left to change0 transaction(s) of Steam Games to change$ python3 c-recategorize-merchant.py "Netflix" "Shopping::Entertainment & Recreation" 1204 transaction(s) of Netflix to change200 {"data": [{"id": "1612469", "changed": true}, {"id": "1612568", "changed": true}, {"id": "1612648", "changed": true}, {"id": "1612733", "changed": true}], "changes": 4}Read, filter, then write. /transactions filters only by date range and account, so the script reads the whole window and picks the merchant out itself. It skips split legs (rows with a split_of), because a write names the parent transaction and a leg id is 400 split_leg_id. The window counts back from the machine’s local date.
The precondition. Each update’s expected holds the parent_category, category and merchant the script read, in the read’s shape: category is the sub-category alone, while the category the update sets is Parent::Sub. If any one row has changed since the read, the whole batch is refused with 409 precondition_failed and the ids it is about, and nothing is written. A row that already holds the new category answers 200 and counts nothing, so a repeated run is safe. A batch takes up to 500 updates; this script sends one batch, and the trip recipe below shows how to send more. Write reference covers the batch and preconditions.
How do I split one transaction?
Section titled “How do I split one transaction?”This script splits one transaction in two: a first leg of a given size in one category and the rest in a second. It needs the transaction’s id and date from /transactions, a token that can change data, and bash with curl and jq, or Python 3.
#!/usr/bin/env bash# Split one transaction in two: a first leg of a given size, the rest in a second# category. There is no single-transaction GET, so the script reads the day the# transaction is on, and sends `expected_splits: []` ("I read it unsplit").# Needs curl and jq; a token that can change data.# Usage: ./d-split-transaction.sh 1611804 2025-12-08 20.00 "Shopping::Clothing" "Shopping::Shopping"set -euo pipefail: "${TAIGA_API:?set TAIGA_API}" "${TAIGA_TOKEN:?set TAIGA_TOKEN}"id=$1; day=$2; first=$3; cat1=$4; cat2=$5auth=(-H "Authorization: Bearer $TAIGA_TOKEN")
txn=$(curl -sS --fail-with-body "${auth[@]}" "$TAIGA_API/api/v1/transactions?from=$day&to=$day&limit=1000" | jq -c --arg id "$id" '[.data[] | select(.id == $id)][0] // empty')[ -n "$txn" ] || { echo "transaction $id not found unsplit on $day" >&2; exit 1; }
# Legs carry the parent's sign and must sum to its amount (to the cent).body=$(jq -c --argjson first "$first" --arg c1 "$cat1" --arg c2 "$cat2" ' (if .amount < 0 then -1 else 1 end) as $sign | ($first * $sign * 100 | round / 100) as $a | { splits: [ {amount: $a, category: $c1}, {amount: ((.amount - $a) * 100 | round / 100), category: $c2} ], expected_splits: [] }' <<<"$txn")
curl -sS -w '\nHTTP %{http_code}\n' -X PUT "$TAIGA_API/api/v1/transactions/$id/splits" "${auth[@]}" \ -H "Content-Type: application/json" -d "$body""""Split one transaction in two: a first leg of a given size, the rest in a secondcategory. There is no single-transaction GET, so the script reads the day thetransaction is on, and sends `expected_splits: []` ("I read it unsplit").
Standard library only; a token that can change data.Usage: python3 d-split-transaction.py 1611804 2025-12-08 20.00 "Shopping::Clothing" "Shopping::Shopping""""import jsonimport osimport sysimport urllib.errorimport urllib.parseimport urllib.requestfrom decimal import Decimal
API = os.environ["TAIGA_API"]TOKEN = os.environ["TAIGA_TOKEN"]
def call(method, path, body=None, **params): url = f"{API}/api/v1{path}" + (f"?{urllib.parse.urlencode(params)}" if params else "") data = None if body is None else json.dumps(body).encode() req = urllib.request.Request(url, data=data, method=method, headers={ "Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}) try: with urllib.request.urlopen(req) as resp: return resp.status, json.load(resp) except urllib.error.HTTPError as e: return e.code, json.load(e)
txn_id, day, first, cat1, cat2 = sys.argv[1:6]status, page = call("GET", "/transactions", **{"from": day, "to": day, "limit": 1000})txn = next((t for t in page["data"] if t["id"] == txn_id), None)if txn is None: sys.exit(f"transaction {txn_id} not found unsplit on {day}")
# Legs carry the parent's sign and must sum to its amount (to the cent): Decimal, not float.amount = Decimal(str(txn["amount"]))leg1 = Decimal(first).copy_sign(amount)body = {"splits": [{"amount": float(leg1), "category": cat1}, {"amount": float(amount - leg1), "category": cat2}], "expected_splits": []}status, result = call("PUT", f"/transactions/{txn_id}/splits", body)print(status, json.dumps(result, indent=2))The shell run split a −61.02 Amazon purchase into −20.00 and −41.02, then ran again and stopped. The Python run split a −33.67 Amazon purchase into −10.00 and −23.67. The answer holds both legs; the first is shown here. The second leg differs from it only in id (-s2), split_slot (2), amount and amount_home, and category (Shopping).
$ ./d-split-transaction.sh 1611804 2025-12-08 20.00 "Shopping::Clothing" "Shopping::Shopping"{ "data": [ { "id": "1611804-s1", "split_of": "1611804", "split_slot": 1, "split_note": null, "date": "2025-12-08", "posted_date": "2025-12-08", "authorized_date": null, "description": "AMAZON", "merchant": "Amazon", "amount": -20.0, "currency": "USD", "amount_home": -20.0, "fx_rate": null, "fx_rate_date": null, "status": "posted", "type": "debit", "parent_category": "Shopping", "category": "Clothing", "counterparty": null, "account_id": "8442", "account_name": "Chase Joint Checking", "institution": "Chase", "hidden_from_budgets": false, "tags": [], "paid_from_fund": null } ], "next_cursor": null, "home_currency": "USD", "as_of": "2026-11-11", "zone": "UTC"}HTTP 200
$ ./d-split-transaction.sh 1611804 2025-12-08 20.00 "Shopping::Clothing" "Shopping::Shopping" # again: it now reads as legstransaction 1611804 not found unsplit on 2025-12-08$ python3 d-split-transaction.py 1611796 2025-12-06 10.00 "Shopping::Clothing" "Shopping::Shopping"200 { "data": [ { "id": "1611796-s1", "split_of": "1611796", "split_slot": 1, "split_note": null, "date": "2025-12-06", "posted_date": "2025-12-06", "authorized_date": null, "description": "AMAZON", "merchant": "Amazon", "amount": -10.0, "currency": "USD", "amount_home": -10.0, "fx_rate": null, "fx_rate_date": null, "status": "posted", "type": "debit", "parent_category": "Shopping", "category": "Clothing", "counterparty": null, "account_id": "8442", "account_name": "Chase Joint Checking", "institution": "Chase", "hidden_from_budgets": false, "tags": [], "paid_from_fund": null } ], "next_cursor": null, "home_currency": "USD", "as_of": "2026-11-11", "zone": "UTC"}Finding the transaction. There is no endpoint for one transaction, so the script reads the transaction’s day and picks it out by id. Once split, the transaction reads as its legs, <id>-s1 and <id>-s2, each with split_of set to the parent’s id, so a second run no longer finds a row with that id and stops.
The legs. Each leg carries the parent’s sign, and the legs must sum to the parent’s amount to the cent, or the write is 422 split_sum_mismatch. The Python script does the arithmetic in Decimal and the shell script rounds to cents in jq, so the second leg is exactly the rest. expected_splits: [] states that the script read the transaction with no splits: if it has been split since, the write is 409 precondition_failed with the current legs. DELETE /transactions/{transaction_id}/splits collapses a split back to one row. Splits are written one transaction at a time; the batch does not take them. Write reference covers the splits endpoints.
How do I split the rent every month?
Section titled “How do I split the rent every month?”This script creates a rule that splits every arriving payment matching a pattern into a fixed rent leg and a remainder utilities leg. Run again with a new amount, it replaces the rule it wrote. It needs a token that can change data, and bash with curl and jq, or Python 3.
#!/usr/bin/env bash# The recurring rent split: a rule that splits every arriving payment matching a# pattern into a fixed rent leg and a remainder utilities leg. It acts on# transactions as they arrive, not on history. Running it again updates the# rule this token already wrote (409 rule_pattern_exists names it; PUT replaces it).# Needs curl and jq; a token that can change data.# Usage: ./e-rent-split-rule.sh "MAPLE RIDGE APTS" 1850.00set -euo pipefail: "${TAIGA_API:?set TAIGA_API}" "${TAIGA_TOKEN:?set TAIGA_TOKEN}"pattern=$1; rent=$2auth=(-H "Authorization: Bearer $TAIGA_TOKEN" -H "Content-Type: application/json")rule=$(jq -nc --arg p "$pattern" --argjson rent "$rent" ' {pattern: $p, match_type: "contains", split_recipe: {legs: [ {category: "Housing::Rent", kind: "fixed", value: $rent}, {category: "Utilities::Utilities", kind: "remainder"}]}}')
out=$(mktemp)code=$(curl -sS -o "$out" -w '%{http_code}' -X POST "$TAIGA_API/api/v1/rules" "${auth[@]}" -d "$rule")if [ "$code" = 409 ] && [ "$(jq -r .detail "$out")" = rule_pattern_exists ]; then id=$(jq -r .rule_id "$out") echo "a rule for this pattern exists ($id); replacing it" code=$(curl -sS -o "$out" -w '%{http_code}' -X PUT "$TAIGA_API/api/v1/rules/$id" "${auth[@]}" -d "$rule")fiecho "HTTP $code"; jq '.data // .' "$out""""The recurring rent split: a rule that splits every arriving payment matching apattern into a fixed rent leg and a remainder utilities leg. It acts ontransactions as they arrive, not on history. Running it again updates the rulethis token already wrote (409 rule_pattern_exists names it; PUT replaces it).
Standard library only; a token that can change data.Usage: python3 e-rent-split-rule.py "MAPLE RIDGE APTS" 1850.00"""import jsonimport osimport sysimport urllib.errorimport urllib.request
API = os.environ["TAIGA_API"]TOKEN = os.environ["TAIGA_TOKEN"]
def call(method, path, body=None): data = None if body is None else json.dumps(body).encode() req = urllib.request.Request(f"{API}/api/v1{path}", data=data, method=method, headers={ "Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}) try: with urllib.request.urlopen(req) as resp: return resp.status, json.load(resp) except urllib.error.HTTPError as e: return e.code, json.load(e)
pattern, rent = sys.argv[1], float(sys.argv[2])rule = {"pattern": pattern, "match_type": "contains", "split_recipe": {"legs": [ {"category": "Housing::Rent", "kind": "fixed", "value": rent}, {"category": "Utilities::Utilities", "kind": "remainder"}]}}
status, body = call("POST", "/rules", rule)if status == 409 and body.get("detail") == "rule_pattern_exists": print(f"a rule for this pattern exists ({body['rule_id']}); replacing it") status, body = call("PUT", f"/rules/{body['rule_id']}", rule)print(status, json.dumps(body.get("data", body), indent=2))The shell run created the rule with a rent of 1,850.00 (201). The Python run, right after it with 1,900.00, found that rule and replaced it (200).
$ ./e-rent-split-rule.sh "MAPLE RIDGE APTS" 1850.00HTTP 201[ { "id": "5610", "pattern": "MAPLE RIDGE APTS", "match_type": "contains", "category": null, "merchant": null, "split_recipe": { "legs": [ { "category": "Housing::Rent", "kind": "fixed", "value": 1850.0 }, { "category": "Utilities::Utilities", "kind": "remainder", "value": null } ] }, "account_id": null, "account_name": null, "account_scoped": false, "account_hidden": false, "amount_min": null, "amount_max": null, "currency": "USD", "app_only_actions": [], "category_valid": true, "yours": true, "writable": true }]$ python3 e-rent-split-rule.py "MAPLE RIDGE APTS" 1900.00 # the rent went up: the same script updates the rulea rule for this pattern exists (5610); replacing it200 [ { "id": "5610", "pattern": "MAPLE RIDGE APTS", "match_type": "contains", "category": null, "merchant": null, "split_recipe": { "legs": [ { "category": "Housing::Rent", "kind": "fixed", "value": 1900.0 }, { "category": "Utilities::Utilities", "kind": "remainder", "value": null } ] }, "account_id": null, "account_name": null, "account_scoped": false, "account_hidden": false, "amount_min": null, "amount_max": null, "currency": "USD", "app_only_actions": [], "category_valid": true, "yours": true, "writable": true }]Arriving transactions only. A rule acts on transactions as they arrive and never on history, so this month’s rent payment, if already in, stays as it is; split it with the previous recipe. A fixed leg’s value is positive and the legs take the transaction’s sign. The remainder leg gets what the fixed legs leave, and a recipe has at most one. When the fixed legs add up to more than the payment, the rule skips the split.
Create or replace. A second rule for a pattern you already hold is 409 rule_pattern_exists with its rule_id, and the script replaces that rule with PUT. A PUT is the whole rule: a field left out is cleared. Only the token that last wrote a rule may change it, so if the existing rule was made in the app, by your partner or by another token, the PUT is 403 not_this_tokens_rule and the script prints that answer. Rules covers conditions, recipes and precedence.
How do I tag a trip?
Section titled “How do I tag a trip?”This script creates a tag, or reuses the one with that name, and adds it to every transaction in a date range while keeping the tags each one already has. It needs a token that can change data, and bash with curl, jq and awk, or Python 3.
#!/usr/bin/env bash# Tag a trip: create the tag (or reuse it), then add it to every transaction in a# date range, keeping the tags each already has. Batches of up to 500, each update# carrying the tags it read as a precondition; backs off on 429 (Retry-After).# Needs curl and jq; a token that can change data.# Usage: ./f-tag-trip.sh "Santa Fe trip" 2026-08-14 2026-08-17set -euo pipefail: "${TAIGA_API:?set TAIGA_API}" "${TAIGA_TOKEN:?set TAIGA_TOKEN}"tag=$1; from=$2; to=$3
call() { # call METHOD URL [BODY]; prints the body, sets $status; retries a 429 after Retry-After local hdr; hdr=$(mktemp) while :; do body=$(curl -sS -D "$hdr" -X "$1" "$2" -H "Authorization: Bearer $TAIGA_TOKEN" \ -H "Content-Type: application/json" ${3:+-d "$3"}) status=$(awk 'NR==1{print $2}' "$hdr") [ "$status" = 429 ] || break sleep "$(awk 'tolower($1)=="retry-after:"{print $2+0}' "$hdr")" done rm -f "$hdr"}
call POST "$TAIGA_API/api/v1/tags" "$(jq -nc --arg n "$tag" '{name: $n}')"echo "tag: HTTP $status $(jq -c '.data[0]' <<<"$body")" # 201 created, 200 reusedname=$(jq -r '.data[0].name' <<<"$body")
rows='[]'; cursor=""while :; do call GET "$TAIGA_API/api/v1/transactions?from=$from&to=$to&limit=1000${cursor:+&cursor=$cursor}" [ "$status" = 200 ] || { echo "HTTP $status: $body" >&2; exit 1; } rows=$(jq -c --argjson acc "$rows" '$acc + .data' <<<"$body") cursor=$(jq -r '.next_cursor // empty' <<<"$body") [ -n "$cursor" ] || breakdone
# A split transaction reads as its legs, each carrying the parent's tags: one update per parent.updates=$(jq -c --arg t "$name" ' [ group_by(.split_of // .id)[] | .[0] | select(.tags | index($t) | not) | {id: (.split_of // .id), tags: (.tags + [$t]), expected_tags: .tags} ]' <<<"$rows")echo "$(jq length <<<"$updates") transaction(s) to tag"for ((i = 0; i < $(jq length <<<"$updates"); i += 500)); do call POST "$TAIGA_API/api/v1/transactions/batch" "$(jq -c --argjson i $i '{updates: .[$i:$i+500]}' <<<"$updates")" echo "batch: HTTP $status $body"done"""Tag a trip: create the tag (or reuse it), then add it to every transaction in adate range, keeping the tags each already has. Batches of up to 500, each updatecarrying the tags it read as a precondition; backs off on 429 (Retry-After).
Standard library only; a token that can change data.Usage: python3 f-tag-trip.py "Santa Fe trip" 2026-08-14 2026-08-17"""import jsonimport osimport sysimport timeimport urllib.errorimport urllib.parseimport urllib.request
API = os.environ["TAIGA_API"]TOKEN = os.environ["TAIGA_TOKEN"]
def call(method, path, body=None, **params): """One request; a 429 waits for Retry-After and tries again.""" url = f"{API}/api/v1{path}" + (f"?{urllib.parse.urlencode(params)}" if params else "") data = None if body is None else json.dumps(body).encode() req = urllib.request.Request(url, data=data, method=method, headers={ "Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}) while True: try: with urllib.request.urlopen(req) as resp: return resp.status, json.load(resp) except urllib.error.HTTPError as e: if e.code != 429: return e.code, json.load(e) time.sleep(int(e.headers.get("Retry-After", "1")))
tag, date_from, date_to = sys.argv[1:4]status, page = call("POST", "/tags", {"name": tag})print("tag:", status, page["data"][0]) # 201 created, 200 reusedname = page["data"][0]["name"]
rows, params = [], {"from": date_from, "to": date_to, "limit": 1000}while True: status, page = call("GET", "/transactions", **params) rows += page["data"] if not page["next_cursor"]: break params["cursor"] = page["next_cursor"]
# A split transaction reads as its legs, each carrying the parent's tags: one update per parent.updates = {}for t in rows: parent = t["split_of"] or t["id"] if parent not in updates and name not in t["tags"]: updates[parent] = {"id": parent, "tags": t["tags"] + [name], "expected_tags": t["tags"]}updates = list(updates.values())print(f"{len(updates)} transaction(s) to tag")for i in range(0, len(updates), 500): status, result = call("POST", "/transactions/batch", {"updates": updates[i:i + 500]}) print("batch:", status, json.dumps(result))The shell run tagged 23 transactions of a four-day trip, then ran again with the tag name typed in another case: the tag was reused and nothing was left to tag. The Python run tagged a three-day weekend.
$ ./f-tag-trip.sh "Santa Fe trip" 2026-08-14 2026-08-17tag: HTTP 201 {"id":"6","name":"Santa Fe trip"}23 transaction(s) to tagbatch: HTTP 200 {"data":[{"id":"1612550","changed":true},{"id":"1612551","changed":true},{"id":"1612552","changed":true},{"id":"1612553","changed":true},{"id":"1612554","changed":true},{"id":"1612555","changed":true},{"id":"1612556","changed":true},{"id":"1612557","changed":true},{"id":"1612558","changed":true},{"id":"1612559","changed":true},{"id":"1612560","changed":true},{"id":"1612561","changed":true},{"id":"1612562","changed":true},{"id":"1612563","changed":true},{"id":"1612564","changed":true},{"id":"1612565","changed":true},{"id":"1612566","changed":true},{"id":"1612567","changed":true},{"id":"1612568","changed":true},{"id":"1613089","changed":true},{"id":"1613090","changed":true},{"id":"1613117","changed":true},{"id":"1613142","changed":true}],"changes":23}
$ ./f-tag-trip.sh "santa fe TRIP" 2026-08-14 2026-08-17 # again: the tag is reused, nothing left to tagtag: HTTP 200 {"id":"6","name":"Santa Fe trip"}0 transaction(s) to tag$ python3 f-tag-trip.py "Moab weekend" 2026-09-19 2026-09-21tag: 201 {'id': '7', 'name': 'Moab weekend'}11 transaction(s) to tagbatch: 200 {"data": [{"id": "1612652", "changed": true}, {"id": "1612653", "changed": true}, {"id": "1612654", "changed": true}, {"id": "1612655", "changed": true}, {"id": "1612656", "changed": true}, {"id": "1612657", "changed": true}, {"id": "1612658", "changed": true}, {"id": "1612659", "changed": true}, {"id": "1612660", "changed": true}, {"id": "1612661", "changed": true}, {"id": "1612662", "changed": true}], "changes": 11}The tag and the tag list. POST /tags answers 201 for a new tag and 200 for an existing one, matching names the way the app matches a typed name, with case and spacing folded. A write sets a transaction’s whole tag list by name and never creates a tag, so the script sends the tags it read plus the new one, with expected_tags holding what it read. A split transaction reads as legs that each carry the parent’s tags, so the script sends one update per parent. Batches go in groups of 500, the most one batch takes.
Backing off on a 429. Both scripts sleep for Retry-After seconds on any 429 and send the same request again. For the per-minute and in-flight limits that is under a minute. The daily cap of 5,000 changes per person is also a 429, write_limit, and its Retry-After runs to the next UTC midnight, so a script that reaches the cap waits until then. Limits and errors lists what counts as a change.
How do I add transactions from a CSV file?
Section titled “How do I add transactions from a CSV file?”This script adds each row of a CSV file to one account, one POST /transactions per row. Each row’s client_id comes from the row itself, so running the script again over the same file adds nothing. It needs the account’s id from /accounts, a token that can change data, and bash with curl, jq and sha256sum, or Python 3. The file has a header and four columns, and the category may be empty:
date,amount,merchant,category2026-11-02,-6.50,Farmers Market,Food::Groceries2026-11-02,-6.50,Farmers Market,Food::Groceries2026-11-05,-20.00,Car wash,Transportation::Car Maintenance2026-11-06,-61.88,Jiffy Lube,2026-11-08,40.00,Garage sale,#!/usr/bin/env bash# Add each row of a CSV file to one account: date,amount,merchant,category (category may be empty).# Usage: ./g-import-csv.sh ACCOUNT_ID FILE.csv# Needs curl, jq and sha256sum; a token that can change data. Fields hold no commas or quotes.set -euo pipefailaccount=$1 file=$2auth=(-H "Authorization: Bearer $TAIGA_TOKEN" -H "Content-Type: application/json")out=$(mktemp) hdr=$(mktemp)trap 'rm -f "$out" "$hdr"' EXITdeclare -A seen
while IFS=, read -r date amount merchant category; do # The client_id comes from the row itself, plus how many identical rows came before it, # so two equal rows stay two transactions and a second run adds nothing. key="$account|$date|$amount|$merchant|$category" n=${seen[$key]:-0}; seen[$key]=$((n + 1)) client_id="csv-$(printf '%s|%s' "$key" "$n" | sha256sum | cut -c1-40)" body=$(jq -n --arg a "$account" --arg d "$date" --argjson amt "$amount" --arg m "$merchant" \ --arg c "$category" --arg id "$client_id" \ '{account_id: $a, date: $d, amount: $amt, merchant: $m, client_id: $id} + (if $c == "" then {} else {category: $c} end)') while :; do code=$(curl -sS -o "$out" -D "$hdr" -w '%{http_code}' -X POST "$TAIGA_API/api/v1/transactions" \ "${auth[@]}" -d "$body") [ "$code" = 429 ] || [ "$code" = 503 ] || break if [ "$(jq -r '.detail' "$out")" = write_limit ]; then echo "stopped at $date $merchant: no changes left today" >&2; cat "$out" >&2; exit 1 fi sleep "$(awk 'tolower($1) == "retry-after:" {print $2 + 0}' "$hdr")" done case $code in 201) what=added ;; 200) what=exists ;; *) echo "refused $date $merchant: HTTP $code $(cat "$out")" >&2; exit 1 ;; esac jq -r --arg w "$what" '"\($w)\t\(.data[0].id)\t\(.data[0].date)\t\(.data[0].amount)\t\(.data[0].merchant)\t\(.data[0].parent_category)::\(.data[0].category)" + (if (.possible_duplicates | length) > 0 then "\tlooks like \(.possible_duplicates | join(", "))" else "" end)' "$out"done < <(tail -n +2 "$file")"""Add each row of a CSV file to one account: date,amount,merchant,category (category may be empty).
Usage: python3 g-import-csv.py ACCOUNT_ID FILE.csvNeeds Python 3 (standard library only); a token that can change data."""import csvimport hashlibimport jsonimport osimport sysimport timeimport urllib.errorimport urllib.request
API = os.environ["TAIGA_API"] + "/api/v1"TOKEN = os.environ["TAIGA_TOKEN"]
def post(body): """POST /transactions, waiting out a 429 or 503 by its Retry-After; stops on write_limit.""" data = json.dumps(body).encode() while True: req = urllib.request.Request(API + "/transactions", data=data, method="POST", headers={ "Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}) try: with urllib.request.urlopen(req) as r: return r.status, json.load(r) except urllib.error.HTTPError as e: answer = json.load(e) if e.code not in (429, 503): sys.exit(f"refused {body['date']} {body['merchant']}: HTTP {e.code} {answer}") if answer.get("detail") == "write_limit": sys.exit(f"stopped at {body['date']} {body['merchant']}: no changes left today {answer}") time.sleep(int(e.headers["Retry-After"]))
def main(account, path): seen = {} with open(path, newline="") as f: for row in csv.DictReader(f): # The client_id comes from the row itself, plus how many identical rows came # before it, so two equal rows stay two transactions and a second run adds nothing. key = "|".join([account, row["date"], row["amount"], row["merchant"], row["category"]]) n = seen.get(key, 0) seen[key] = n + 1 client_id = "csv-" + hashlib.sha256(f"{key}|{n}".encode()).hexdigest()[:40] body = {"account_id": account, "date": row["date"], "amount": float(row["amount"]), "merchant": row["merchant"], "client_id": client_id} if row["category"]: body["category"] = row["category"] status, answer = post(body) t = answer["data"][0] line = [("added" if status == 201 else "exists"), t["id"], t["date"], str(t["amount"]), t["merchant"], f"{t['parent_category']}::{t['category']}"] if answer["possible_duplicates"]: line.append("looks like " + ", ".join(answer["possible_duplicates"])) print("\t".join(line))
if __name__ == "__main__": main(sys.argv[1], sys.argv[2])The shell run added the five rows (201 each), then a second run over the same file found all five (200 each). The Python run used the same file with one row added at the end, and added only that row.
$ ./g-import-csv.sh 8565 cash-november.csvadded 1658942 2026-11-02 -6.5 Farmers Market Food::Groceriesadded 1658943 2026-11-02 -6.5 Farmers Market Food::Groceries looks like 1658942added 1658944 2026-11-05 -20.0 Car wash Transportation::Car Maintenanceadded 1658945 2026-11-06 -61.88 Jiffy Lube Transportation::Car Maintenance looks like 1637577added 1658946 2026-11-08 40.0 Garage sale Miscellaneous::Uncategorized
$ ./g-import-csv.sh 8565 cash-november.csv # again: every row is already thereexists 1658942 2026-11-02 -6.5 Farmers Market Food::Groceries looks like 1658943exists 1658943 2026-11-02 -6.5 Farmers Market Food::Groceries looks like 1658942exists 1658944 2026-11-05 -20.0 Car wash Transportation::Car Maintenanceexists 1658945 2026-11-06 -61.88 Jiffy Lube Transportation::Car Maintenance looks like 1637577exists 1658946 2026-11-08 40.0 Garage sale Miscellaneous::Uncategorized$ python3 g-import-csv.py 8565 cash-november-2.csv # the same rows plus one new oneexists 1658942 2026-11-02 -6.5 Farmers Market Food::Groceries looks like 1658943exists 1658943 2026-11-02 -6.5 Farmers Market Food::Groceries looks like 1658942exists 1658944 2026-11-05 -20.0 Car wash Transportation::Car Maintenanceexists 1658945 2026-11-06 -61.88 Jiffy Lube Transportation::Car Maintenance looks like 1637577exists 1658946 2026-11-08 40.0 Garage sale Miscellaneous::Uncategorizedadded 1658947 2026-11-10 -12.0 Food truck Food::Dining OutOne client_id per row. The client_id is a hash of the account and the row’s fields, plus how many identical rows came before it in the file. The two equal market rows stay two transactions, and a create whose client_id was used before answers 200 with the transaction the first run added, so a second run adds nothing. An edited row hashes to a new client_id, so it is added as a new transaction. The shell script reads plain comma-separated fields; a field with a comma in it needs the Python script, which reads quoted CSV.
Possible duplicates. The script prints possible_duplicates after a row. The Jiffy Lube row looks like 1637577, the bank’s charge of the same day and amount, and each market row looks like the other. Nothing is refused: DELETE /transactions/{transaction_id} removes a transaction the script added. A row with no category is placed by your rules and the app’s categorizer, which put Jiffy Lube in Transportation / Car Maintenance and left the garage sale Uncategorized.
Backing off on a 429. Both scripts sleep for Retry-After seconds on a 429 or a 503 and send the same request again, and the client_id keeps a retry from adding a second copy. Each row added counts one change against the daily cap of 5,000, and on write_limit the scripts stop, because its Retry-After runs to the next UTC midnight. Run again the next day, a script skips the rows already added. With one change left for the day, the Python script over the same file with two more rows added one and stopped:
$ python3 g-import-csv.py 8565 cash-november-3.csv # two new rows, one change left todayexists 1658942 2026-11-02 -6.5 Farmers Market Food::Groceries looks like 1658943exists 1658943 2026-11-02 -6.5 Farmers Market Food::Groceries looks like 1658942exists 1658944 2026-11-05 -20.0 Car wash Transportation::Car Maintenanceexists 1658945 2026-11-06 -61.88 Jiffy Lube Transportation::Car Maintenance looks like 1637577exists 1658946 2026-11-08 40.0 Garage sale Miscellaneous::Uncategorizedexists 1658947 2026-11-10 -12.0 Food truck Food::Dining Outadded 1658948 2026-11-11 -4.0 Parking meter Transportation::Transportationstopped at 2026-11-11 Food truck: no changes left today {'detail': 'write_limit', 'remaining': 0}(exit 1)Coming from Lunch Money or YNAB
Section titled “Coming from Lunch Money or YNAB”The table maps the write concepts of the Lunch Money API and the YNAB API to the Taiga Finance API. The read concepts are on Recipes.
| Lunch Money | YNAB | Taiga Finance /api/v1 |
|---|---|---|
| Categories, category groups | Category groups, categories | A write sets a Parent::Sub pair from GET /categories; categories cannot be created or edited through the API |
| Payee | Payee | merchant, set by PATCH /transactions/{transaction_id}; no payee list endpoint |
| Tags | Flags | GET /tags and POST /tags; PUT /transactions/{transaction_id}/tags sets the whole list, by name |
| Notes | Memo | One note per token per transaction, PUT, GET and DELETE /transactions/{transaction_id}/note, kept as a comment in the transaction’s thread |
| Split transactions | subtransactions |
PUT /transactions/{transaction_id}/splits and DELETE /transactions/{transaction_id}/splits |
| Rules | — | GET, POST, PUT and DELETE /rules: category, merchant and split recipe, on arriving transactions only |
| Bulk update | PATCH /budgets/{id}/transactions |
POST /transactions/batch: up to 500 transactions, all or nothing, category, merchant and tags |
| Create and delete transactions | Create transactions | POST /transactions adds one transaction per request, with an optional client_id that makes a retry safe; DELETE /transactions/{transaction_id} deletes one the API added, while the bank hasn’t matched it and nobody has changed it in the app |
To revert what a script changed, Undo a token’s changes covers ending the token and reverting its changes from Settings.