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:

MethodHeaderExample
JWT BearerAuthorization: Bearer <token>Authorization: Bearer eyJhbGciOi...
API Keyx-api-key: <key> or ?apikey=<key>x-api-key: fnp_3eab...

Auth flow

  1. Email + codePOST /auth/send-code → receive 6-digit code via email → POST /auth/verify-code → get JWT token
  2. Email + passwordPOST /auth/login → get JWT token
  3. OAuthGET /auth/external/:provider/redirect → callback → JWT token
  4. Telegram — deep-link or /start command → 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-locale and 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 creating src/i18n/{code}.json.
  • Fallback: if the header is missing or the locale is unknown, en is used.

What gets translated

ChannelTranslated byHow
Email (subjects, body)Backend (I18nService)Translated before rendering to HTML
Telegram messagesBackend (I18nService)Translated before sending
API error messagesFrontendBackend returns raw keys (e.g. order.not_found), frontend translates via next-intl
In-app notificationsFrontendBackend 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

HeaderRequiredDescription
AuthorizationYes (protected routes)Bearer <jwt>
x-api-keyAlternative to JWTAPI key for programmatic access
fp-localeNoUI locale code (en, uk). Auto-synced to user profile.
Content-TypeYes (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.

EntityExample IDFormat
Userk5Xz9qR2WpAlphanumeric
Order80-472109X0-YYYYY (numeric)
API KeyQxPYVp4dy9Alphanumeric
TransactionaBcDeFgHAlphanumeric
TopupxYzAbCdEAlphanumeric

Pagination

Paginated endpoints accept:

ParamDefaultMaxDescription
page1Page number (1-based)
limit20100Items 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 *Usd and *Display fields.

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

ServiceDocs
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

ServiceDocs
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

ServiceDocs
OG image generation./api-og-internal
Telegram webhooks./api-telegram-internal
Pricing formulas./pricing-internal
Changelog./api-changes-internal