API endpoints
While there are hundreds of available endpoints, the categories below cover the basics to get you started.
Submit transactions
You can submit a transaction with POST /transaction
. You'll need a Vega Wallet app or signer library to prepare your transaction before sending.
If you use Go, you can import Vega as a dependency, and use the code under wallet/pkg ↗ to sign and send your transaction.
Description | Documentation | Call |
---|---|---|
Submit a transaction | Submit transaction | POST /transaction |
Get blockchain height | Get height | GET /blockchain/height |
Get the current Vega time | Get Vega time | GET /time |
Check your spam statistics | Get spam statistics | GET /spam/statistics |
Transaction samples
Follow the guide to sending transactions to sign and send using the command line wallet.
Submit order
This is a partial example of an order submission.
{
"orderSubmission": {
"marketId": "1234",
"price": "42",
"size":10,
"side": "SIDE_BUY",
"timeInForce": "TIME_IN_FORCE_FOK",
"type": "TYPE_LIMIT"
}
}
See the commands API for all fields, including optionals.
Amend order
Change an existing order. If you leave a field unset - if it was used on your original order - or with a default value, the field's value will not change.
{
"orderAmendment": {
"marketId": "1234",
"price": "42",
"sizeDelta":10,
"side": "SIDE_BUY",
"timeInForce": "TIME_IN_FORCE_FOK",
"type": "TYPE_LIMIT"
}
}
See the commands API for all fields, including optionals.
Cancel order
Cancel an existing order, or all orders on a market. If you use the market ID, it will cancel all orders on that market.
{
"orderCancellation": {
"orderId": "42",
}
}
Submit stop orders
Submit a stop order - a normal order that remains off the order book and is only submitted if a given trigger is breached from a particular direction. If both rises-above and falls-below are configured, then if one is triggered the other will be cancelled (OCO).
{
"stopOrdersSubmission": {
"OrderSubmission": {
"marketId": "1234",
"price": "42",
"size":10,
"side": "SIDE_BUY",
"timeInForce": "TIME_IN_FORCE_FOK",
"type": "TYPE_LIMIT"
}
"expiresAt": "42",
"expiryStrategy":10,
"sizeOverrideSetting": "SIDE_BUY",
"sizeOverrideValue": "TIME_IN_FORCE_FOK",
"trailingPercentOffset": "TYPE_LIMIT",
"price": "TYPE_LIMIT"
}
}
Cancel stop order
Cancel untriggered stop orders by specifing which stop order using its ID, or cancel all your stop orders on a given market using the market ID. If any cancelled stop order is part of an OCO, both stop orders will be cancelled.
{
"stopOrdersCancellation": {
"orderId": "42",
}
}
Switch between cross and isolated margin
Change the margin mode you're using on a market by including the mode to switch to. When changing to isolated margin mode, include the margin amount you want as a decimal amount where 1 = 100%.
{
"updateMarginMode": {
"marketId" "1234"
"mode": "MODE_ISOLATED_MARGIN",
"marginFactor": "0.2"
}
}
Parties
A party is a single user, defined as a Vega public key. As one person or entity can have many public keys, this is a unique identifier as far as an individual key's actions. Party ID and public key (pubkey) are all names for the same thing.
Description | Documentation | Call |
---|---|---|
See a paginated list of parties | List parties | GET /api/v2/parties |
Assets
Assets used on Vega originate on external chains, not the Vega chain.
Inter-chain asset interactions can be:
- Between Vega and Ethereum, and facilitated through the Ethereum bridge.
- Between Vega and Arbitrum, faciliated through the Arbitrum bridge.
Assets can only be added to the network to be used as collateral through a successful governance proposal and enactment, and a follow-on update to the relevant asset bridge.
Description | Documentation | Call |
---|---|---|
See all assets that can be used on the network | List assets | GET /api/v2/assets |
Show a specific asset's details | Asset | GET /api/v2/asset/:assetId |
Deposits and withdrawals
Assets can be deposited using a web3 wallet:
- Via the Ethereum bridge contract, for ERC-20 assets on Ethereum mainnet
- Via the Arbitrum bridge, for assets on the Arbitrum mainnet network
Read more about the asset bridges.
Assets can be withdrawn back into an external wallet if they are not being used for margin, positions, or liquidity bond.
Description | Documentation | Call |
---|---|---|
See all deposits for a specific public key | List deposits | GET /api/v2/deposits |
See a specific deposit using its ID | Deposit | GET /api/v2/deposit/:id |
Understanding the concepts: accounts | Accounts | |
Understanding the concepts: deposits and withdrawals | Deposits and withdrawals |
Accounts
Vega relies on accounts to ensure funds are never lost or double spent. The amounts in each account, as well as the transactions that were added to and removed from those accounts, are all recorded and stored on-chain. Accounts are used either to hold assets that the public key holder is in control of using — such as deposited collateral, or for setting money aside that only the network can manage — to fulfil margin requirements, for example, or to store assets that are earmarked for rewards or paying out fees.
Description | Documentation | Call |
---|---|---|
List accounts based on chosen filters | List accounts | GET /api/v2/accounts |
Understanding the concepts: accounts | Accounts |
Governance proposals and voting
Governance proposals used to add new assets and markets, as well as to suggest changes to assets, markets, and network parameters, as well as off-chain suggestions. Governance tokens need to be associated to the Vega public key that wants to take part in governance.
Description | Documentation | Call |
---|---|---|
View all governance proposals with their current state, paginated | List proposals | GET /api/v2/governances |
Get detailed information about a specific governance proposal using its ID | Proposal | GET /api/v2/governance |
How to submit proposals using command line | Submitting proposals | |
Understanding the concepts: Governance | Governance |
Governance token
A governance token is used for taking part in network, market, asset and freeform governance, and to secure a network by nominating validators that run it.
Description | Documentation | Call |
---|---|---|
See a list of votes | List votes | GET /api/v2/votes |
How to nominate validators using the smart contracts | Stake tokens | |
Understand the concepts: Governance | Governance |