Datafeed adapter guide
We do not ship a self-hosted charting library today. Partners can still power TradingView-style chart libraries or custom dashboards by implementing a datafeed against our public REST API and WebSocket quotes.
Recommended pattern
- Resolve symbols with
GET /v1/public/symbols. - Load history with
GET /v1/public/historyand map ISO timestamps to bar times. - Stream live updates from
/v1/stream/quotesand synthesize partial bars client-side. - Gate features such as seconds bars and real-time equities with the entitlements returned from your account tier.
Example adapter skeleton
javascript
// Minimal IDatafeed-style adapter backed by CandleScript public API
export function createCandleScriptDatafeed({ baseUrl, apiKey }) {
const headers = { Authorization: `Bearer ${apiKey}`, Accept: "application/json" };
return {
onReady(cb) {
cb({ supported_resolutions: ["1", "5", "15", "60", "1D", "1W"] });
},
resolveSymbol(symbolName, onResolve) {
fetch(`${baseUrl}/v1/public/symbols?query=${encodeURIComponent(symbolName)}`, { headers })
.then((r) => r.json())
.then(({ symbols }) => {
const match = symbols[0];
onResolve({
name: match.id,
ticker: match.id,
session: "0930-1600",
timezone: "America/New_York",
minmov: 1,
pricescale: 100,
has_intraday: true,
supported_resolutions: ["1", "5", "15", "60", "1D", "1W"]
});
});
},
getBars(symbolInfo, resolution, periodParams, onHistory, onError) {
const qs = new URLSearchParams({
symbol: symbolInfo.ticker,
resolution,
from: new Date(periodParams.from * 1000).toISOString(),
to: new Date(periodParams.to * 1000).toISOString()
});
fetch(`${baseUrl}/v1/public/history?${qs}`, { headers })
.then((r) => r.json())
.then(({ bars }) => {
onHistory(
bars.map((b) => ({
time: Date.parse(b.ts),
open: b.open,
high: b.high,
low: b.low,
close: b.close,
volume: b.volume
})),
{ noData: bars.length === 0 }
);
})
.catch(onError);
},
subscribeBars() {},
unsubscribeBars() {}
};
}Prefer a smaller integration surface? Use native fetch against the documented REST endpoints or embed our mini-chart widget. The repository's internal API client is not a published npm package.