1. Log in to get a token
curl -X POST /api/login \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "supersecret123"
}'
const res = await fetch('/api/login', {
method: 'POST',
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
body: JSON.stringify({ email: '[email protected]', password: 'supersecret123' }),
});
const { access_token } = await res.json();
localStorage.setItem('token', access_token);
$ch = curl_init('/api/login');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'email' => '[email protected]',
'password' => 'supersecret123',
]),
]);
$response = json_decode(curl_exec($ch), true);
$token = $response['access_token'];
import requests
res = requests.post(
'/api/login',
headers={'Accept': 'application/json'},
json={'email': '[email protected]', 'password': 'supersecret123'},
)
token = res.json()['access_token']
2. Record a transaction
curl -X POST /api/transactions \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"account_id": 1,
"category_id": 2,
"type": "expense",
"amount": 25.50,
"description": "Lunch with team",
"transaction_date": "2026-06-03"
}'
await fetch('/api/transactions', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + token,
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
account_id: 1,
category_id: 2,
type: 'expense',
amount: 25.50,
description: 'Lunch with team',
transaction_date: '2026-06-03',
}),
});
$ch = curl_init('/api/transactions');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_TOKEN',
'Accept: application/json',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'account_id' => 1,
'category_id' => 2,
'type' => 'expense',
'amount' => 25.50,
'description' => 'Lunch with team',
'transaction_date' => '2026-06-03',
]),
]);
$transaction = json_decode(curl_exec($ch), true);
import requests
requests.post(
'/api/transactions',
headers={'Authorization': f'Bearer {token}'},
json={
'account_id': 1,
'category_id': 2,
'type': 'expense',
'amount': 25.50,
'description': 'Lunch with team',
'transaction_date': '2026-06-03',
},
)