General API
FonProxy General API reference documentation.
FonProxy API — General
Base URL:
https://api.fonproxy.io(production) /http://localhost:3100(dev)
Authentication
All protected endpoints require one of:
| Method | Header | Example |
|---|---|---|
| JWT Bearer | Authorization: Bearer <token> | Authorization: Bearer eyJhbGciOi... |
| API Key | x-api-key: <key> or ?apikey=<key> | x-api-key: fnp_3eab... |
Auth flow
- Email + code —
POST /auth/send-code→ receive 6-digit code via email →POST /auth/verify-code→ get JWT token - Email + password —
POST /auth/login→ get JWT token - OAuth —
GET /auth/external/:provider/redirect→ callback → JWT token - Telegram — deep-link or
/startcommand →POST /auth/telegram/verify→ JWT token
Full auth docs: ./api-auth
Locale
The API uses the fp-locale header to determine the user's language.
fp-locale: uk
Behaviour
- Every request: the backend reads
fp-localeand uses it for server-rendered content (emails, Telegram notifications). - Logged-in users: if the header value differs from the stored locale, the backend automatically updates the user's locale in the database (fire-and-forget, no extra request needed).
- Supported locales:
en(English, default),uk(Ukrainian). More can be added by creatingsrc/i18n/{code}.json. - Fallback: if the header is missing or the locale is unknown,
enis used.
What gets translated
| Channel | Translated by | How |
|---|---|---|
| Email (subjects, body) | Backend (I18nService) | Translated before rendering to HTML |
| Telegram messages | Backend (I18nService) | Translated before sending |
| API error messages | Frontend | Backend returns raw keys (e.g. order.not_found), frontend translates via next-intl |
| In-app notifications | Frontend | Backend stores raw keys in DB, frontend renders |
The locale field is always returned in the user profile (GET /user/me) so the frontend can initialise its own i18n accordingly.
Common Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes (protected routes) | Bearer <jwt> |
x-api-key | Alternative to JWT | API key for programmatic access |
fp-locale | No | UI locale code (en, uk). Auto-synced to user profile. |
Content-Type | Yes (POST/PATCH) | application/json |
Response Format
All responses are JSON. Success responses return the relevant data directly:
{
"user": { "id": "k5Xz9qR2Wp", "name": "John", ... }
}
Error responses:
{
"message": "order.not_found",
"path": "/orders/80-12345",
"timestamp": "2026-04-01T12:00:00.000Z"
}
The message field is a translation key — the frontend resolves it to a human-readable string.
IDs (Hashids)
All public-facing entity IDs are encoded with Hashids. Internal numeric IDs are never exposed.
| Entity | Example ID | Format |
|---|---|---|
| User | k5Xz9qR2Wp | Alphanumeric |
| Order | 80-472109 | X0-YYYYY (numeric) |
| API Key | QxPYVp4dy9 | Alphanumeric |
| Transaction | aBcDeFgH | Alphanumeric |
| Topup | xYzAbCdE | Alphanumeric |
Pagination
Paginated endpoints accept:
| Param | Default | Max | Description |
|---|---|---|---|
page | 1 | — | Page number (1-based) |
limit | 20 | 100 | Items per page |
Response includes:
{
"items": [...],
"total": 142,
"page": 1,
"pages": 8
}
Currency
- All prices and balances are stored in USD internally.
- Display values are converted using live exchange rates.
- The user's preferred display currency is set via
PATCH /user/settings { "currency": "UAH" }. - Endpoints that return monetary values include both
*Usdand*Displayfields.
Rate Limiting
Throttled by IP address. Default: 60 requests/minute for most endpoints, 5/minute for auth endpoints.
When rate-limited, the API returns 429 Too Many Requests:
{ "message": "error.rate_limit" }
API Reference
Public
| Service | Docs |
|---|---|
| Authentication | ./api-auth |
| User & Settings | ./api-user |
| Orders | ./api-order |
| Payments | ./api-payment |
| API Keys | ./api-keys |
| Notifications | ./api-notifications |
| Geo (countries) | ./api-geo |
| Referral | ./api-referral |
| Analytics | ./api-analytics |
| Search | ./api-search |
| Tracking (visitors) | ./api-tracking |
| Health | ./api-health |
| Docs (markdown) | ./api-docs |
Admin
| Service | Docs |
|---|---|
| Admin overview | ./api-admin |
| Users | ./api-admin-users |
| Orders | ./api-admin-orders |
| Transactions | ./api-admin-transactions |
| Pools | ./api-admin-pools |
| Sources | ./api-admin-sources |
| IPs | ./api-admin-ips |
| Peers | ./api-admin-peers |
| Notifications | ./api-admin-notifications |
| Referrals | ./api-admin-referrals |
| Geo multipliers | ./api-admin-geo |
| Visitors | ./api-admin-visitors |
Internal
| Service | Docs |
|---|---|
| OG image generation | ./api-og-internal |
| Telegram webhooks | ./api-telegram-internal |
| Pricing formulas | ./pricing-internal |
| Changelog | ./api-changes-internal |