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.- Sign in to the Connect dashboard with your email, and create your app in the sandbox.
- Open API keys, name a key, and create it.
trdrs_ck_sandbox_ and works only in the sandbox.
Put it in your shell, beside the sandbox’s address:
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: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, Start the server in the shell that holds your two variables:It prints
trader-test-1, where your server names the trader
your own sign-in verified.server.mjs
index.html
Open http://localhost:8787.3
Open hosted Connect
Open A The
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:connected event is a signal for your page, never proof. Confirm on your server by reading the
link: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 The response’s
x-trdrs-trader. List the trader’s accounts: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 The response names the order and how it filled: its
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.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 answers409, 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 get404trader_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 readsmounted, notconnected. - 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=$ACCOUNTwith{ "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.