-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full Node Endpoints #261
Full Node Endpoints #261
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
{ | ||
"full_node_endpoints": "Full Node Endpoints", | ||
"full_node_streaming": "Full Node gRPC Streaming" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Full Node Endpoints | ||
Full nodes provide two APIs: | ||
|
||
- [Full Node API](#full-node-api) for native full node features | ||
- [CometBFT API](#cometbft-api) for CometBFT state | ||
|
||
Use these APIs to read the latest network data, to place orders quickly and efficiently, and to build upon with your own custom software. | ||
|
||
## Getting Started | ||
|
||
The Full Node and CometBFT APIs offer different sets of functionality. They accept different query frameworks. Choose the query method and tool for your use case. | ||
|
||
### Choose Query Method | ||
|
||
The Full Node API accepts gRPC or REST. The CometBFT API accepts only RPC. | ||
|
||
|| Full Node API | CometBFT API | | ||
| ---- | --- | ------ | | ||
| gRPC | ✅ | ✖ | | ||
| REST | ✅ | ✖ | | ||
| RPC | ✖ | ✅ | | ||
|
||
### Install Query Tools | ||
|
||
You can use your own query tool, or your can install one or both of the following CLI tools: | ||
|
||
- [grpcurl](https://github.com/fullstorydev/grpcurl?tab=readme-ov-file#installation) to send gRPC and RPC requests | ||
- [curl](https://curl.se/download.html) to send RESTful requests | ||
|
||
### Find Your Node URL | ||
|
||
To query a full node, you need its URL. If you are running and querying your own full node on the same system, that URL is usually `localhost`. If you want to use an infrastructure provider's public full node, use a URL from the **Full Node Endpoints** section of the [resources page](../infrastructure_providers-network/resources#full-node-endpoints). Choose a node for your deployment type and query method. | ||
|
||
Then, check your connection to your target node using the command for your use case: | ||
|
||
|| Full Node API | CometBFT API | | ||
| ------ | ------------- | ------------ | | ||
| gRPC | `grpcurl --plaintext <url>.dydxprotocol` | ✖ | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is right:
|
||
| REST | `curl <url>/dydxprotocol/` | ✖ | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that the expected response is "Not Implemented"
|
||
| RPC | ✖ | `grpcurl --plaintext <url>.status` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RPC should be checked through CURL not gRPC |
||
|
||
## Full Node API | ||
The Full Node API provides an identical set of | ||
[gRPC endpoints](#grpc) and | ||
[REST endpoints](#rest-grpc-gateway). You can use either framework. Generally, [gRPC](https://grpc.io/) provides a faster connection. | ||
|
||
### gRPC Endpoints | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that gRPC and REST endpoints are the same, just with different protocols for access, I'd think it makes more sense to combine the gRPC and REST sections into "Full Node Endpoints", and then show the example requests for both gRPC and REST. |
||
You can interact with the Full Node API using [grpcurl](https://github.com/fullstorydev/grpcurl?tab=readme-ov-file#installation) or your own tool to send gRPC requests. The gRPC server is available on port `9090` by default. | ||
|
||
See the [API specification]() for gRPC endpoints. | ||
|
||
**Examples** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO examples would be clearer if they used a live node URL from a specific deployment, like https://dydx-ops-rest.kingnodes.com/ directly, so you can link e.g. straight to https://dydx-ops-rest.kingnodes.com/dydxprotocol/vault/params, and have a separate section explaining that you can substitute your node's address for the base URL. |
||
|
||
Get your USDC balance: | ||
```bash | ||
grpcurl --plaintext http://examplenode:9090 api.Service/Method | ||
``` | ||
|
||
Get a list of instruments available to trade on a node's network: | ||
```bash | ||
grpcurl --plaintext http://examplenode:9090 api.Service/Method | ||
``` | ||
|
||
Convert human-readable trade information into integers and quantums: | ||
```bash | ||
grpcurl --plaintext http://examplenode:9090 api.Service/Method | ||
``` | ||
|
||
Place and broadcast an order: | ||
```bash | ||
grpcurl --plaintext http://examplenode:9090 api.Service/Method | ||
``` | ||
|
||
Get a list of your open positions: | ||
```bash | ||
grpcurl --plaintext http://examplenode:9090 api.Service/Method | ||
``` | ||
|
||
Get your liquidation price: | ||
```bash | ||
grpcurl --plaintext http://examplenode:9090 api.Service/Method | ||
``` | ||
|
||
### REST Endpoints | ||
You can interact with the Full Node API using `curl` or your own tool to send RESTful requests. Nodes provide support for REST through [gRPC-Gateway](https://grpc-ecosystem.github.io/grpc-gateway/). The gRPC-Gateway server is available on port `1317` by default. | ||
|
||
See the [Silk Nodes API specification](https://dydx.api.silknodes.io/swagger/#/) for REST endpoints. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense to link the swagger spec, but having it hosted elsewhere could be confusing (what is silknodes?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the same vein, I think it makes sense to link to the gRPC query service definitions underlying the gRPC endpoints. Maybe just have a quick paragraph explaining how to find the source code for a given endpoint. One of the cool things about DC, for an API user, is that you can just "read the code". |
||
|
||
**Examples** | ||
|
||
Get your USDC balance: | ||
```bash | ||
curl https://examplenode:1317/path/to/resource | ||
``` | ||
|
||
Get the height of the network: | ||
```bash | ||
curl https://examplenode:1317/path/to/resource | ||
``` | ||
|
||
## CometBFT API | ||
You can read CometBFT state information using [grpcurl](https://github.com/fullstorydev/grpcurl?tab=readme-ov-file#installation) or your own tool to send RPC requests. The RPC server is available on port `26657` by default. | ||
|
||
See the [CometBFT RPC v0.38 API specification](https://docs.cometbft.com/v0.38/rpc) for CometBFT endpoints. | ||
|
||
**Examples** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think "stream the height of the network" (rather than query) is the most important one |
||
|
||
Get your USDC balance: | ||
```bash | ||
grpcurl --plaintext http://examplenode:26657 api.Service/Method | ||
``` | ||
|
||
Get the height of the network: | ||
```bash | ||
grpcurl --plaintext http://examplenode:26657 api.Service/Method | ||
``` |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,3 +1,3 @@ | ||||||
# Full Node gRPC Streaming | ||||||
|
||||||
This page has moved to [API Integration > Full Node Streaming API](../api_integration-full-node-streaming.md). | ||||||
This page has moved to [API Integration > Full Node Streaming](../api_integration-full-node-streaming.md). | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth distinguishing between REST and (Comet's) RPC? Both are JSON over HTTP. I think it's technically correct to separate them but might be confusing.