Transparent, non-custodial, yours

Web3 developer guide: your first market API request

A practical guide to the public FBT market API: working curl and JavaScript examples, chart and candle endpoints, error handling and key safety.

Data scope Public, read-only for the example market endpoints
Authentication Not required for the public market examples
Charts Price history and OHLC use separate endpoints

FBT Swap

What you should know

This quickstart is for a client that reads public market data — not one that signs transactions or moves a user’s funds. Both examples call the market endpoint, and neither needs a private API key.

API responses depend on upstream limits, caching and network availability. Check HTTP status, cache results and back off when rate-limited. This service does not promise uptime or an SLA for your application.

Before building against a new route, read the machine-readable contract. Documentation used by an integration should match the server response; do not assume an endpoint is supported if it is absent from OpenAPI.

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.

API

Request examples

curl request
curl -fsS "https://fbtswap.ir/api/markets?per_page=5" \
  -H "accept: application/json"
Read the same API in JavaScript
const response = await fetch("/api/markets?per_page=5", {
  headers: { accept: "application/json" }
});
if (!response.ok) throw new Error("HTTP " + response.status);
const markets = await response.json();
console.table(markets.slice(0, 5));

At a glance

At a glance

Data scope

Public, read-only for the example market endpoints

Authentication

Not required for the public market examples

Charts

Price history and OHLC use separate endpoints

Reliability

Cache upstream data and surface failures honestly

FAQ

Frequently asked questions

Clear answers before you decide.

Do I need an API key for market data?

The public read-only examples in this guide do not require a user key. Check /api/openapi.json for the exact access boundary of each route.

Does the API guarantee prices or uptime?

No. Data depends on upstream services and caching, and there is no guaranteed uptime or SLA. Your client should make missing or failed data explicit.

Should I fetch a separate chart for each of 30 tokens?

For a 30-asset table, use /api/markets?per_page=30; the response includes seven-day sparkline data. Unnecessary fan-out consumes shared upstream quota.

Risk notice

Crypto assets are volatile and on-chain transactions cannot be reversed. You can lose money, including all of it. Nothing here is financial advice.