Todos los ejemplos dan por hecho que tienes el token en una variable de entorno:
export MISFINANZAS_API_KEY="mfd_..."
export MISFINANZAS_API="https://enjcwrocbfwhtofxfjyo.supabase.co/functions/v1/api"
Cuánto gasté el mes pasado
curl -s "$MISFINANZAS_API/v1/summary?year=2026&month=7" \
-H "Authorization: Bearer $MISFINANZAS_API_KEY" \
| jq '.expenses.total'
Las cinco categorías donde más gasto
curl -s "$MISFINANZAS_API/v1/summary?year=2026" \
-H "Authorization: Bearer $MISFINANZAS_API_KEY" \
| jq '.expenses.by_category[:5] | .[] | "\(.name): \(.total) €"'
Apuntar un gasto
Necesitas el category_id, que sale de /v1/categories:
curl -s "$MISFINANZAS_API/v1/entries" \
-X POST \
-H "Authorization: Bearer $MISFINANZAS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "expense",
"category_id": "3f6b1c2e-9a4d-4c1f-8b7e-2d5a6c8e1f90",
"year": 2026,
"month": 8,
"amount": 34.90,
"description": "Renovación del dominio"
}'
Buscar la categoría por nombre y apuntar el gasto
En JavaScript, sin dependencias:
const API = process.env.MISFINANZAS_API;
const KEY = process.env.MISFINANZAS_API_KEY;
const headers = {
Authorization: `Bearer ${KEY}`,
'Content-Type': 'application/json',
};
async function apuntarGasto(nombreCategoria, importe, descripcion) {
const res = await fetch(`${API}/v1/categories?type=expense`, { headers });
const { data: categorias } = await res.json();
const categoria = categorias.find(
(c) => c.name.toLowerCase() === nombreCategoria.toLowerCase()
);
if (!categoria) {
throw new Error(`No existe la categoría "${nombreCategoria}"`);
}
const hoy = new Date();
const respuesta = await fetch(`${API}/v1/entries`, {
method: 'POST',
headers,
body: JSON.stringify({
type: 'expense',
category_id: categoria.id,
year: hoy.getFullYear(),
month: hoy.getMonth() + 1,
amount: importe,
description: descripcion,
}),
});
if (!respuesta.ok) {
const { error } = await respuesta.json();
throw new Error(`${error.code}: ${error.message}`);
}
return respuesta.json();
}
await apuntarGasto('Suscripciones', 34.9, 'Renovación del dominio');
Exportar el año a CSV
En Python:
import csv
import os
import requests
API = os.environ["MISFINANZAS_API"]
KEY = os.environ["MISFINANZAS_API_KEY"]
headers = {"Authorization": f"Bearer {KEY}"}
def descargar_todo(tipo, year):
apuntes, offset = [], 0
while True:
r = requests.get(
f"{API}/v1/entries",
headers=headers,
params={"type": tipo, "year": year, "limit": 200, "offset": offset},
)
r.raise_for_status()
cuerpo = r.json()
apuntes.extend(cuerpo["data"])
if not cuerpo["pagination"]["has_more"]:
return apuntes
offset += 200
with open("gastos-2026.csv", "w", newline="", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(["mes", "categoria", "importe", "descripcion"])
for apunte in descargar_todo("expense", 2026):
writer.writerow([
apunte["month"],
(apunte.get("category") or {}).get("name", ""),
apunte["amount"],
apunte.get("description") or "",
])
Fíjate en el bucle de paginación: sin él te quedarías en los primeros 200 apuntes.
Evolución del patrimonio
curl -s "$MISFINANZAS_API/v1/net-worth/history?from_year=2024" \
-H "Authorization: Bearer $MISFINANZAS_API_KEY" \
| jq -r '.data[] | "\(.year)-\(.month|tostring|(length|if .==1 then "0" else "" end) + tostring): \(.total) €"'
Cómo va la cartera
curl -s "$MISFINANZAS_API/v1/holdings" \
-H "Authorization: Bearer $MISFINANZAS_API_KEY" \
| jq '.totals'
{
"count": 12,
"value": 84210.55,
"cost": 71300.00,
"pnl": 12910.55,
"pnl_percent": 18.11
}