1. Start with one safe public request
GET /api/markets?per_page=5 reads a ranked market list from the same origin. The public market endpoints in this guide do not need a user API key. Still check response.ok and validate the response shape; an upstream provider can be temporarily unavailable.
In a browser client, use the relative /api path so the request stays on the same origin. From another service, use https://fbtswap.ir/api and verify CORS and usage details in OpenAPI and the server response.
2. Use the right endpoint for lines and candles
GET /api/chart/bitcoin?days=7 returns price history. For candlesticks, GET /api/ohlc/bitcoin?days=30 returns open, high, low and close data. Both describe historical observations; neither promises a future price.
One request to /api/markets?per_page=30 can supply a 30-asset table and each row’s seven-day sparkline. Do not fan out to thirty separate chart requests for that view.
3. Handle errors, caching and credentials deliberately
Keep 4xx and 5xx responses separate from valid market data; never store a failed request as a zero price. Cache according to the data type, use exponential backoff, and respect 429 or Retry-After when present.
Do not put a provider or model key in a VITE_ variable, frontend bundle or APK: those values are public. Keep private credentials in the server environment. The public FBT market examples do not require a user key.
4. Build from the machine-readable API contract
The read endpoints, parameters and service boundaries are described at /api/openapi.json. Use it to generate types and validate inputs; do not treat write or internal routes as a public integration surface.
Before release, test empty data, timeouts, malformed responses, rate limits and upstream outages. If your application depends on a feed for a financial decision or a displayed price, show “data unavailable” rather than a made-up value.