Skip to main content
This quickstart runs the whole Connect journey once, in the sandbox. You’ll get an API key, add your website, offer white-label paper, open hosted Connect for a test trader on a page you serve, and route an order on the Demo that trader opens. Use this page the first time you build on Connect. By the end you have a test trader holding a Demo they opened in hosted Connect on your page, and an order of theirs that your backend routed. Everything here runs in the sandbox, which is free. You need curl and Node.js 20 or later.

Get your API key

You create your app and its API key in the Connect dashboard, where your team signs in with an email code. Your app’s API key is your backend’s key: it has a name and an expiry, and carries exactly what your trading interface needs.
  1. Sign in to the Connect dashboard with your email, and create your app in the sandbox.
  2. Open API keys, name a key, and create it.
The key is shown once, so copy it now. It starts trdrs_ck_sandbox_ and works only in the sandbox. Put it in your shell, beside the sandbox’s address:
Check the key with one read that changes nothing: the accounts of a trader no Connect link has named yet.
You get 404 trader_not_found: the key works. An id becomes one of your traders the first time a Connect link names it, which this quickstart does below. A 401 invalid_key means the key is wrong, revoked or expired, or the base URL isn’t the sandbox.

Add your website

Hosted Connect opens only on a website you added, so add the one this quickstart serves its page on. In the Connect dashboard, open Websites and add:
A sandbox website is approved at once. A website is an exact origin: its scheme, host and port, with no path and no trailing slash. It must use https, except http on localhost while you develop, so http://localhost:8787 and http://127.0.0.1:8787 are two different websites.
1

Offer white-label paper

Switch on your white-label paper, so your test trader can open a Demo with nothing to type. In the Connect dashboard, open Connect and switch on white-label paper at its starting balance of 100,000 US dollars.Your Connect now shows your white-label paper first, under your app’s name. Tiles and white-label paper covers both settings.
2

Serve a page that opens Connect

Your page asks your server for a Connect link, and your server creates one for the trader it signed in, with your API key. Save these two files in an empty folder. The server stands in for your own sign-in: it names one test trader, trader-test-1, where your server names the trader your own sign-in verified.
server.mjs
index.html
Start the server in the shell that holds your two variables:
It prints Open http://localhost:8787.
3

Open hosted Connect

Open http://localhost:8787, using exactly that address, and press Connect a trading account. Hosted Connect opens over your page, with your white-label paper first, under your app’s name. Pick it and confirm. There’s nothing to type: the trader’s Demo opens at the balance you set, Connect closes, and your page says Connected.Your server printed the Connect link’s id. Put it in your shell:
A connected event is a signal for your page, never proof. Confirm on your server by reading the link:
The link reads "state": "connected", names your trader in trader, and carries the Demo’s accountId in result. The trader is connected.
4

Read the trader's accounts

From now on your server names the trader on every request: your API key, and your own id for them in x-trdrs-trader. List the trader’s accounts:
The response’s accounts holds the Demo: provider is paper, accountNumber starts DEMO-, and balance is 100000. Only this trader’s accounts appear. Put the two values the trading routes name the account by in your shell:
5

Route the trader's first order

Before an order, ask what the account may do on the instrument. It runs the checks an order runs without sending anything, and on the paper book it readies the instrument’s prices for the order that follows. The examples trade HYPERLIQUID:BTC, the Bitcoin perpetual, whose prices come from a public feed, so they run in the sandbox.
actions.open.allowed is true. Now route the order, as your interface would when the trader presses Buy. clientOrderId makes it safe to retry: send the same id again and the order is never placed twice.
The response names the order and how it filled: its providerOrderId, filledQty of 0.01 and avgFillPrice. The trader holds 0.01 bitcoin on their Demo, and your integration works.If the order answers 422 market_data_unavailable with params.cause mark_missing, the instrument’s first price hadn’t reached the account yet. Wait a few seconds and send the same request again, with the same clientOrderId.

Test it end to end

Everything above ran in the sandbox. Before you build on it, check the parts you’ll rely on:
  • Retry the order. Send the order request again with the same clientOrderId. It answers 409, and the trader still holds 0.01, not 0.02.
  • Name a trader trdrs doesn’t know. List the accounts of trader-test-2, an id no Connect link has named. You get 404 trader_not_found: an id becomes one of your traders the first time a Connect link names it.
  • Close Connect without connecting. Open Connect again and close it. Your page hears closed, and the new link reads mounted, not connected.
  • Connect a second trader. Stop the server, start it again with TRADER=trader-test-2 node server.mjs, and open your white-label paper again. The new trader holds a Demo of their own, and each trader’s account list shows only their own Demo.
  • Close the position. Send POST /api/trading/flatten?provider=$PROVIDER&account=$ACCOUNT with { "instrument": "HYPERLIQUID:BTC" }, your API key and the trader’s id. The Demo is flat again.

Next steps

Connect SDK

Learn every option, event and error of hosted Connect on your page.

Route your traders' orders

Read accounts and streams, and route, move and cancel your traders’ orders.

Tiles and white-label paper

Choose the tiles your Connect offers, and run your traders’ Demos.

Pass conformance

Run your app’s whole journey through the graded sandbox check.