4.4 API
Read API
The RPC gives verified data. You must have an RPC key. Make it on www.defisilicon.com/rpc. The page also shows the RPC address and examples.
| Data | Endpoint |
|---|---|
| Account balances, orders and positions | /api/v1/accounts/{account}/balances |
| One of your keys | /api/v1/accounts/address/{key} |
| Markets, order book, trades | see the RPC page |
How a command goes to the exchange
- Make it. Each command is 256 bytes. It contains the chain, the account, the nonce, the action and an Ed25519 signature.
- Count it. Each trading key has its own nonce sequence. The ledger accepts a command only with the next nonce. Execution uses the nonce, also when the ledger rejects the action.
- Send it. The command goes as one UDP datagram to each site that you select. The session key of the site authenticates it.
- Wait for the result. The ACK means "accepted". The receipt means "executed". The certificate means "final".
| Action | Code |
|---|---|
| Place | 1 |
| Place with flags (reduce-only, IOC, post-only) | 22 |
| Cancel | 2 |
| Replace | 15 |
| Post-only replace | 29 |
| Add or remove margin | 23 |
| Set leverage | 25 |
SDK
The kit contains a Python SDK and a native client. The native client signs commands and checks proofs. Use the SDK, not raw datagrams. It sends again after rejections, and it keeps the nonce state safe.