Skip to main content
Load the bars a chart needs, let the trader scroll back through older ones, and know when there’s nothing older to load. Use this page when you’re drawing a chart from Get price history. The route has two ways to ask. A window asks for the bars between two times. A count asks for a number of bars before a point in time, which is what a chart wants when the trader scrolls left. By the end you can load both, stop scrolling at the right moment, and hand over to the live stream.

Before you start

The examples use TRDRS_API_BASE_URL and TRDRS_TRADING_API_KEY from the programmatic quickstart and chart HYPERLIQUID:BTC, the Bitcoin perpetual, whose prices come from a provider’s public data, so they run in the sandbox with no other login. The TypeScript SDK isn’t published, so call the route over HTTP, as the curl examples do. The TypeScript examples show the same calls through the SDK’s client. A futures contract, such as ESZ6, loads the same way. So does a continuous symbol, which loads the contract its position names when you ask: ES1! the front contract and ES2! the one after it. Futures prices are licensed to each user and come from their own login at a provider that carries them (Providers lists which), so futures history loads in a trader’s own signed-in session at trdrs. A Trading API key loads crypto history, and a futures request it sends is refused with 503 and feed_requires_connection. The same holds for the futures spreads below.
1

Load the latest bars

Ask with just an instrument and a timeframe, and you get about the latest 500 bars. It’s the fastest way to put a chart on screen.
Each bar is { t, o, h, l, c, v }: the time the bar opened in epoch seconds, then open, high, low, close and volume. Bars come oldest first, one per time.
2

Load a window

Add from and to, in epoch seconds. Both ends are included.
A window can be at most limits.maxBars bars wide, 5,000, measured at the timeframe you ask for. A wider window is refused with 400, so ask for a coarser timeframe or a shorter span.
3

Scroll back with a count

countBack asks for that many bars at or before to, from 1 to limits.maxBars. When the trader drags the chart left, set to to the time of the oldest bar you hold and ask again.
Leave from out when you send countBack: the count wins and from is ignored. A count reaches back across weekends and holidays until it finds the bars, up to limits.maxBars.
4

Hand over to the live stream

Open a bar stream alongside history for the same instrument and timeframe. Display its cached snapshot, apply live bars, and replace the recent window when its repaired snapshot arrives.
Stream live data covers the events.

Know when to stop scrolling

Two fields tell a chart that older bars won’t come. Each appears only when it’s true, so treat a missing field as false. A chart that ignores noData keeps asking for pages that will never exist. A chart that ignores stale shows Friday’s bars as if the market were open on Saturday.

Chart a spread

instrument can be an expression over up to four instruments instead of one symbol, such as HYPERLIQUID:BTC/HYPERLIQUID:ETH, ES-NQ or (ES+NQ)/2. It loads, resolves and streams like a single instrument. A Trading API key charts a spread of perpetuals, and a spread with a futures instrument in it needs futures data, as Before you start explains. A string that exactly matches a catalog symbol is always that symbol, even when it contains a / or a -. If any one instrument in a spread is refused, the whole spread is refused.

When history is refused

For futures, the 503 codes tell three situations apart: Any other 503 carries no code, and its error is market_data_unavailable.

Next steps

Stream live data

Keep the chart live after the history loads.

Find symbols

Read the tick and price format the bars are written in.

Build a front end

Put the chart on your own site with Quick Charts.