Tous les exemples supposent la clé dans la variable d’environnement COUICOUI_API_KEY.
curl et jq
API=https://www.couicoui.com/api/v1
AUTH="Authorization: Bearer $COUICOUI_API_KEY"
# Soldes de tous les comptes, en euros
curl -s "$API/list_accounts" -H "$AUTH" \
| jq -r '.data.accounts[] | "\(.name)\t\(.balance_cents / 100) \(.currency)"'
# Recettes et dépenses mois par mois depuis janvier
curl -s "$API/monthly_breakdown?from=2026-01-01&to=2026-12-31" -H "$AUTH" | jq '.data'
# Qui me doit de l’argent ?
curl -s "$API/list_receivables?state=overdue" -H "$AUTH" | jq '.data'
JavaScript / TypeScript
Un client minimal, sans dépendance (Node 18+, Deno, Bun, navigateur côté serveur) :
const BASE = 'https://www.couicoui.com/api/v1'
export async function couicoui<T = unknown>(endpoint: string, params: Record<string, unknown> = {}): Promise<T> {
const res = await fetch(`${BASE}/${endpoint}`, {
method: 'POST', // lecture seule : POST sert juste à transporter les paramètres
headers: {
Authorization: `Bearer ${process.env.COUICOUI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
})
if (res.status === 429) {
const wait = Number(res.headers.get('retry-after') ?? '5')
await new Promise((r) => setTimeout(r, wait * 1000))
return couicoui<T>(endpoint, params)
}
const body = await res.json()
if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message} (${body.meta.request_id})`)
return body.data as T
}
// Utilisation
const { accounts } = await couicoui<{ accounts: Array<{ name: string; balance_cents: number }> }>('list_accounts')
const october = await couicoui('analyze_period', { from: '2026-10-01', to: '2026-10-31' })
Toutes les transactions d’une période, page par page :
async function allTransactions(from: string, to: string) {
const rows = []
for (let offset = 0; ; offset += 100) {
const page = await couicoui<{ transactions: unknown[]; total: number }>('list_transactions', {
from, to, limit: 100, offset, sort_order: 'asc',
})
rows.push(...page.transactions)
if (offset + 100 >= page.total) return rows
}
}
Python
import os, time, requests
BASE = "https://www.couicoui.com/api/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['COUICOUI_API_KEY']}"
def couicoui(endpoint: str, **params):
while True:
r = session.post(f"{BASE}/{endpoint}", json=params, timeout=30)
if r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", "5")))
continue
body = r.json()
if not r.ok:
raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
return body["data"]
# Export CSV des dépenses du trimestre
import csv
rows, offset = [], 0
while True:
page = couicoui("list_transactions", **{
"side": "debit", "from": "2026-07-01", "to": "2026-09-30", "limit": 100, "offset": offset,
})
rows += page["transactions"]
offset += 100
if offset >= page["total"]:
break
with open("depenses-t3.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["date", "libellé", "contrepartie", "montant €"])
for t in rows:
# amount_cents est toujours positif ; le sens est donné par side
w.writerow([t["occurred_at"][:10], t["label"], t.get("counterpart"), -t["amount_cents"] / 100])
from étant un mot réservé en Python, passez les paramètres par dictionnaire (**{"from": …}).
Google Sheets (Apps Script)
Extensions → Apps Script, collez le code, puis enregistrez votre clé dans Paramètres du projet → Propriétés du script sous le nom COUICOUI_API_KEY.
function couicoui_(endpoint, params) {
const key = PropertiesService.getScriptProperties().getProperty('COUICOUI_API_KEY')
const res = UrlFetchApp.fetch('https://www.couicoui.com/api/v1/' + endpoint, {
method: 'post',
contentType: 'application/json',
headers: { Authorization: 'Bearer ' + key },
payload: JSON.stringify(params || {}),
muteHttpExceptions: true,
})
const body = JSON.parse(res.getContentText())
if (res.getResponseCode() !== 200) throw new Error(body.error.message)
return body.data
}
/** Remplit la feuille « Mois » avec recettes, dépenses et solde net par mois. */
function rafraichirMois() {
const year = new Date().getFullYear()
const data = couicoui_('monthly_breakdown', { from: year + '-01-01', to: year + '-12-31' })
const sheet = SpreadsheetApp.getActive().getSheetByName('Mois') || SpreadsheetApp.getActive().insertSheet('Mois')
// Chaque mois : { month: "2026-10", totals: { EUR: { credit_cents, debit_cents, net_cents, count } } }
const rows = data.months.map(function (m) {
const t = m.totals.EUR || { credit_cents: 0, debit_cents: 0, net_cents: 0 }
return [m.month, t.credit_cents / 100, t.debit_cents / 100, t.net_cents / 100]
})
sheet.clear()
sheet.getRange(1, 1, 1, 4).setValues([['Mois', 'Recettes €', 'Dépenses €', 'Net €']])
if (rows.length) sheet.getRange(2, 1, rows.length, 4).setValues(rows)
}
Ajoutez un déclencheur horaire (Déclencheurs → Ajouter) pour rafraîchir chaque matin.
Recettes
| Besoin | Endpoint | Paramètres utiles |
|---|---|---|
| Solde actuel | list_accounts | — |
| Solde à une date | account_balance_at_date | account_id, at |
| Combien j’ai dépensé / gagné | sum_transactions | from, to |
| Bilan d’une période | analyze_period | from, to, top_counterparts |
| Douze derniers mois | monthly_breakdown | from, to |
| Comparer deux périodes | compare_periods | voir la référence |
| Retrouver une transaction | search_all, find_transactions_by_pattern, search_transactions_around_amount | query, pattern, montant |
| Factures impayées | list_receivables | state=overdue |
| Clients à relancer | detect_late_clients | late_threshold_days |
| Trésorerie à 30/60/90 jours | forecast_cash_flow_by_due_date | horizon_days, client_delay_days |
| Autonomie de trésorerie | cash_runway | currency |
| Abonnements oubliés | find_dormant_subscriptions | — |
| Prochains prélèvements | upcoming_bills | — |
| Déclaration URSSAF | urssaf_declaration_helper | period |
| Provision URSSAF suffisante ? | provisioning_status, urssaf_provisioning_plan | — |
| Prélèvement à la source | impots_pas_history | — |
| Paiements France Travail | francetravail_payments | — |
| Logement partagé ce mois-ci | housing_overview | housing_id |
| Retrouver un justificatif | list_documents puis get_document_link | q, year, sources |