> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cosmos.network/llms.txt
> Use this file to discover all available pages before exploring further.

# API reference

> The interfaces exposed by a Cosmos SDK node, how they relate, and what this reference covers.

Cosmos SDK modules define their queries and transaction messages in protobuf. A node exposes them through gRPC and REST, while the CLI provides commands for using them. CometBFT exposes a separate API for consensus and node data.

This section documents these interfaces. For how applications register them, see [CLI, gRPC, and REST API](/sdk/latest/learn/concepts/cli-grpc-rest).

## Interfaces

| Interface                                                | Default address   | Default  | Purpose                                                                                |
| -------------------------------------------------------- | ----------------- | -------- | -------------------------------------------------------------------------------------- |
| [gRPC](/sdk/latest/api-reference/grpc/index)             | `localhost:9090`  | Enabled  | Query application state and access supporting services                                 |
| [REST](/sdk/latest/api-reference/rest/bank/allbalances)  | `localhost:1317`  | Disabled | Call gRPC methods through HTTP and JSON                                                |
| [CometBFT RPC](/cometbft/latest/api-reference/rpc/index) | `127.0.0.1:26657` | Enabled  | Query blocks, validators, and the mempool; broadcast transactions; subscribe to events |
| [CLI](/sdk/latest/learn/concepts/cli-grpc-rest#cli)      | n/a               | n/a      | Query state and build, sign, and broadcast transactions                                |

## How they relate

Modules usually define two protobuf services:

* A `Query` service for reading application state
* A `Msg` service describing the state changes transactions can request

### Queries

Query methods are callable through gRPC on port 9090. Methods with a `google.api.http` binding are also available through REST on port 1317.

For example, these calls reach the same query handler:

```text theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
cosmos.bank.v1beta1.Query/AllBalances
GET /cosmos/bank/v1beta1/balances/{address}
```

Without an HTTP binding, a method is available only through gRPC.

### Transaction messages

`Msg` methods are not callable endpoints. They define messages that are encoded into transactions, signed, and broadcast through a transaction service:

```text theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
cosmos.tx.v1beta1.Service/BroadcastTx     gRPC
POST /cosmos/tx/v1beta1/txs               REST
broadcast_tx_sync                         CometBFT RPC
```

### CLI

The CLI is a client. Query commands call the application’s query services. Transaction commands construct and sign module messages, then broadcast the resulting transaction. See [Using the CLI](/sdk/latest/node/interact-node#using-the-cli) for worked examples, and [CLI](/sdk/latest/learn/concepts/cli-grpc-rest#cli) for how it fits with the other interfaces.

Most commands are not written by hand: [`autocli`](/sdk/latest/guides/tooling/autocli) generates one per gRPC service method, which is why a command and a `grpcurl` call usually take the same arguments.

Examples in this reference use `simd`, but each chain normally provides its own application-specific binary.

### CometBFT RPC

CometBFT RPC is separate from the application APIs. It belongs to the consensus engine beneath the Cosmos SDK and exposes blocks, validators, consensus data, the mempool, transaction broadcasting, and event subscriptions.

See the [CometBFT RPC reference](/cometbft/latest/api-reference/rpc/index).

## What this section covers

| Page                                                           | Contents                                                         |
| -------------------------------------------------------------- | ---------------------------------------------------------------- |
| [gRPC services](/sdk/latest/api-reference/grpc/index)          | Service names, field encodings, reflection, and pagination       |
| REST                                                           | Generated OpenAPI documentation with a playground for each route |
| [Sending transactions](/sdk/latest/api-reference/transactions) | How to build, sign, and broadcast transactions                   |

Each module page includes both kinds of declaration. For example, the `bank` page documents `Query/AllBalances` and `MsgSend`.

To list the gRPC services registered by a running node:

```bash theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
grpcurl -plaintext localhost:9090 list
```

## Enable the interfaces

gRPC is enabled by default. Enable REST in `app.toml`:

```toml theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[api]
enable = true
address = "tcp://localhost:1317"

# Serve the generated OpenAPI document at /swagger.
swagger = true

[grpc]
enable = true
address = "localhost:9090"
```

Configure CometBFT RPC in `config.toml`:

```toml theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[rpc]
laddr = "tcp://127.0.0.1:26657"
```
