Using Vega’s APIs
Introduction to APIs at Vega
There are complete REST, gRPC, and GraphQL APIs to suit your integration needs. Whether developing a bot, web app, or custom trading script, the APIs we document below are the same as used by the Vega Console to provide a reference trading user interface.
The diagram above shows an example Vega API architecture, including the relationship between nodes:
- APIs are typically hosted by non-validator Vega nodes and in the future a smaller set of APIs will be available on validator nodes if configured.
- Vega Wallets can be hosted locally, or in the cloud, and there’s a helpful REST API built into the reference wallet implementation which can assist API clients with signing and key management.
Which API type is best to integrate with?
Depending on your preference of coding language and streaming requirements, we provide the following recommendations:
We would recommend gRPC for fast and efficient communication with Vega’s APIs. gRPC supports near real time streaming of updates from Vega. gRPC/Protobuf is the transport of choice for many web3 apps.
If you’re already familiar with GraphQL or writing a modern web application, we would recommend GraphQL for its flexibility and ability to retrieve data efficiently with Vega’s APIs. Like gRPC, GraphQL supports near real time streaming of updates from Vega. It uses websockets under the hood but follows the specification for streaming as set by GraphQL.
REST is the ubiquitous protocol for the web, and one that many still rely on. It’s verbose but pretty easy to get started with and Vega supports nearly all the functionality provided by gRPC and GraphQL on the REST APIs. Sadly, REST does not support streaming.
How do I get an API key for Vega?
We don’t provide API keys. All endpoints are public, in that anyone can call them. However, some endpoints require messages to be cryptographically signed in order to verify that the person sending the message is in control of the associated private key. To do so a user must interact with a Vega Wallet.
What are the Testnet API server addresses?
Load-balanced access to API nodes:
n06.testnet.vega.xyz:3007(gRPC is available on all API data-nodes below on port 3007)
Using the load balancer is convenient, however for best performance it is recommended that users connect directly to a node from the list below.
Geographical API data-nodes (non-validator):
For gRPC, go direct to a node near you:
- Europe, Netherlands:
- Europe, Finland:
- Asia, Hong Kong:
- North America, USA (Virginia):
- Asia, Japan:
Hosted Wallet API:
Please see the section on Introducing Fairground for more information on the Vega testnet including total number of nodes, limitations and upcoming features.
How do decimal places work in API calls?
The API deals entirely in whole numbers, so assets are labelled with a decimal place indicator to help API users convert prices to their correct value.
How do I use websockets with Vega APIs?
There are currently no stand-alone websocket based streaming APIs, however we recommend looking at the GraphQL subscriptions feature which provides streaming updates and under the hood uses the websocket protocol for data transmission. GraphQL is very flexible and powerful for modern client integrations.
How do I contribute to the project?
If you have found an issue or would like to suggest an improvement with the public code samples, please raise an issue on the appropriate GitHub repository.
Do you have API reference docs available?
Yes, there are auto-generated API docs for the following: