# RPC API

There are three types of RPC APIs available: gRPC, REST and CometBFT RPC, that enables submitting transactions and querying data.

## Comparison Table

The following table compares the differences between the gRPC, REST and CometBFT RPC endpoints.

<table><thead><tr><th>Name</th><th width="256.3333333333333">Advantages</th><th>Disadvantages</th></tr></thead><tbody><tr><td><strong>gRPC</strong></td><td><ul><li>can use code-generated stubs in various languages</li><li>supports streaming and bidirectional communication (HTTP/2)</li><li>small wire binary sizes, faster transmission</li></ul></td><td><ul><li>based on HTTP/2, not available in some browsers</li><li>learning curve (mostly due to Protobuf)</li></ul></td></tr><tr><td><strong>REST</strong></td><td><p></p><ul><li>ubiquitous</li><li>client libraries in all languages, faster implementation<br></li></ul></td><td><ul><li>only supports unary request-response communication (HTTP/1.1)</li><li>bigger over-the-wire message sizes (JSON)</li><li><strong>heavily rate-limited by public endpoints</strong></li></ul></td></tr><tr><td><strong>CometBFT RPC</strong></td><td><ul><li>easy to use</li><li>has endpoints that allow querying txs by event type</li><li>has websocket support for streaming data</li></ul></td><td><ul><li>bigger over-the-wire message sizes (JSON)</li><li>due to scalability issues, many documented endpoints <strong>may be disabled or heavily rate-limited by public endpoints</strong></li></ul></td></tr></tbody></table>

## Endpoints

These public endpoints can be used to query the Demex L1 chain.

### gRPC

**MainNet:** `https://grpc.carbon.network`

**TestNet:** `https://test-grpc.carbon.network`

### REST

**MainNet:** `https://api.carbon.network`

**TestNet:** `https://test-api.carbon.network`

### CometBFT RPC

**MainNet:** `https://tm-api.carbon.network`

**TestNet:** `https://test-tm-api.carbon.network`

{% hint style="warning" %}
It is important to note that the above public endpoints do not have any guarantees on uptime and may not always be accessible, even when the blockchain may operating normally.&#x20;
{% endhint %}

{% hint style="success" %}
To ensure maximum reliability, it is advisable to [run your own node](https://guide.dem.exchange/technical/running-a-node) with off-chain persistence enabled.
{% endhint %}

## Documentation

### REST

The API docs for Carbon are split into two, depending on whether they are for the custom modules (e.g. broker, etc.) on Carbon, or for modules that come standard with Cosmos-SDK (e.g. auth, bank, staking etc.):

* The specific RPC endpoints for Carbon can be found on Carbon's Swagger page:\
  [https://api.carbon.network/swagger/](https://api.carbon.network/swagger/#/).
* The generic RPC endpoints for Cosmos-SDK modules can be found in the subpage:\
  <https://api.carbon.network/swagger/?urls.primaryName=Cosmos+SDK+v0.50.5>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guide.dem.exchange/technical/rpc-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
