benzuko

API reference

Base URL: /api. All responses are JSON. Errors share the shape { error: string, code: string, details?: unknown }.

GET /api/health

Liveness probe.

GET /api/offers

Returns P2P offers for a side.

Offer shape: see types/index.ts.

curl "http://localhost:3000/api/offers?side=sell"

POST /api/trades

Opens an escrow-locked trade.

curl -X POST http://localhost:3000/api/trades \
  -H 'Content-Type: application/json' \
  -d '{"side":"buy","asset":"USDT","amount":500,"price":119.85,"currency":"BDT","counterparty":"Rahim T.","method":"Wise"}'

Rate limiting

Fixed-window, in-memory (lib/rate-limit.ts), keyed by x-forwarded-for. Defaults: 60 requests / 60s. Swap for Redis/Upstash in production.

Error codes

| Code | HTTP | Meaning | | — | — | — | | BAD_REQUEST | 400 | Malformed input | | VALIDATION_ERROR | 422 | Zod validation failed | | RATE_LIMITED | 429 | Too many requests |