fx-chartingDocs
Data

REST API

restDatafeed connects a bars URL in one call — with polling or a WebSocket for live data.

js
import { FxChart, restDatafeed } from "@fx-charting/pro";

const datafeed = restDatafeed({
  symbols: ["AAPL", "MSFT", "TSLA"],
  url: "https://api.example.com/v1/bars?symbol={symbol}&tf={interval}&to={toSec}&limit={countBack}",
  parse: (json) => json.results,                    // where the bars are in the response
  fetchOptions: { headers: { Authorization: `Bearer ${process.env.NEXT_PUBLIC_API_KEY}` } },
  poll: 5000,                                         // live updates by polling (0 = off)
});
PlaceholderValue
{symbol}Ticker (URL-encoded)
{interval}"1" … "240", "1D", "1W", "1M"
{from} / {to}Times in milliseconds
{fromSec} / {toSec}Times in seconds
{countBack}Number of bars wanted

Different interval names on your API? Pass url as a function: url: (req) => `…&tf=${MAP[req.interval]}`.

Keep secret API keys on your server: point url at your own Next.js route that adds the key and forwards the request.