Quickstart
Use the validator API for live chain data. Use the REST API for hosted authentication and signing.
1. Choose an environment
| Environment | Trading app | Validator API | REST API | Expected chain ID |
|---|---|---|---|---|
| Mainnet | https://v4.parcl.co | https://validator.v4.parcl.co | https://api.v4.parcl.co | parcl-v4:mainnet:chain-1 |
| Devnet | https://devnet.v4.parcl.co | https://v4-api.dev.parcllabs.com | https://v4-rest-api.dev.parcllabs.com | parcl-v4:devnet:chain-2 |
The examples below use devnet. Keep the app, APIs, and chain ID in one environment.
curl https://v4-api.dev.parcllabs.com/v1/node/info2. Create and fund an account
Sign in at the trading app. On devnet, the onboarding flow supplies test assets. On mainnet, deposit supported Solana USDC through the bridge. The app displays any minimum needed to activate a new account.
Open your profile and copy your Parcl Chain public key. Then find your account ID:
curl https://v4-api.dev.parcllabs.com/v1/accounts/by-owner/0xYOUR_PUBLIC_KEYUse the returned accountId in transactions.
3. Read markets and fees
curl https://v4-api.dev.parcllabs.com/v1/markets
curl https://v4-api.dev.parcllabs.com/v1/fee-tiersResolve the market by ID and confirm both status and oracleStatus before every exposure-increasing order. Fail closed unless the oracle is Active. Preserve reduce-only orders and cancellation so a degraded oracle does not trap existing exposure.
Read an order book:
curl https://v4-api.dev.parcllabs.com/v1/markets/0/orderbook4. Create an API key
Create an API key on the devnet Profile → Keys page. It can trade and request a community-vault share withdrawal, but it cannot request an off-platform bridge withdrawal, manage agent keys, or export the hosted signing key. Copy it when shown.
Export the values used by the example:
export PARCL_API_KEY=prcl_sk_YOUR_KEY
export PARCL_ACCOUNT_ID=YOUR_ACCOUNT_ID5. Submit an order
This example generates the nonce and timestamp at submission time. It places a small IOC market order on devnet market 0. A market order can execute immediately and lose money. Change the side or size only after reviewing the live book.
export {};
declare const process: {
env: Record<string, string | undefined>;
};
const restUrl =
process.env.PARCL_REST_URL ?? "https://v4-rest-api.dev.parcllabs.com";
const accountId = Number(process.env.PARCL_ACCOUNT_ID);
const apiKey = process.env.PARCL_API_KEY;
if (!Number.isSafeInteger(accountId) || !apiKey) {
throw new Error("Set PARCL_ACCOUNT_ID and PARCL_API_KEY");
}
const response = await fetch(`${restUrl}/tx/sign-and-submit`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": apiKey,
},
body: JSON.stringify({
transaction: {
PlaceOrder: {
account_id: accountId,
market_id: 0,
side: "Long",
order_type: "Market",
price: 0,
size: 100000,
trigger_price: null,
reduce_only: false,
post_only: false,
time_in_force: "IOC",
take_profit: null,
stop_loss: null,
},
},
nonce: Date.now(),
timestamp: Math.floor(Date.now() / 1000),
}),
});
console.log(response.status, await response.json());The REST service signs the exact transaction for the hosted account. For local signing, use an agent key and follow the transaction byte rules.
6. Stream live data
Open a WebSocket and subscribe to the required market channels. The order-book tracker has runnable examples for TypeScript, Rust, Go, and Python.
See authentication, transactions, and the WebSocket reference for the complete contracts.