Cosmos REST API
The Cosmos REST API provides HTTP endpoints for querying chain state and broadcasting transactions.
Base URLs
| Network | URL |
|---|---|
| Sprintnet | https://api.sprintnet.monolythium.com |
| Testnet | https://api.testnet.monolythium.com |
| Mainnet | https://api.monolythium.com |
Default port: 1317
Common Endpoints
Node Information
# Node info
GET /cosmos/base/tendermint/v1beta1/node_info
# Syncing status
GET /cosmos/base/tendermint/v1beta1/syncing
# Latest block
GET /cosmos/base/tendermint/v1beta1/blocks/latest
Bank Module
# Account balance
GET /cosmos/bank/v1beta1/balances/{address}
# Total supply
GET /cosmos/bank/v1beta1/supply
# Specific denom supply
GET /cosmos/bank/v1beta1/supply/by_denom?denom=alyth
Staking Module
# All validators
GET /cosmos/staking/v1beta1/validators
# Specific validator
GET /cosmos/staking/v1beta1/validators/{validator_addr}
# Delegations for address
GET /cosmos/staking/v1beta1/delegations/{delegator_addr}
# Pool info
GET /cosmos/staking/v1beta1/pool
Distribution Module
# Delegator rewards
GET /cosmos/distribution/v1beta1/delegators/{delegator_addr}/rewards
# Validator commission
GET /cosmos/distribution/v1beta1/validators/{validator_addr}/commission
Governance Module
# All proposals
GET /cosmos/gov/v1beta1/proposals
# Specific proposal
GET /cosmos/gov/v1beta1/proposals/{proposal_id}
# Proposal votes
GET /cosmos/gov/v1beta1/proposals/{proposal_id}/votes
Auth Module
# Account info
GET /cosmos/auth/v1beta1/accounts/{address}
Query Examples
Get Account Balance
curl https://api.sprintnet.monolythium.com/cosmos/bank/v1beta1/balances/mono1abc...
Response:
{
"balances": [
{
"denom": "alyth",
"amount": "1000000000000000000000"
}
],
"pagination": {
"next_key": null,
"total": "1"
}
}
Get Validator Info
curl https://api.sprintnet.monolythium.com/cosmos/staking/v1beta1/validators/monovaloper1abc...
Get Latest Block
curl https://api.sprintnet.monolythium.com/cosmos/base/tendermint/v1beta1/blocks/latest
Broadcasting Transactions
Simulate Transaction
POST /cosmos/tx/v1beta1/simulate
Content-Type: application/json
{
"tx_bytes": "CpQBCp...",
"mode": "BROADCAST_MODE_SYNC"
}
Broadcast Transaction
POST /cosmos/tx/v1beta1/txs
Content-Type: application/json
{
"tx_bytes": "CpQBCp...",
"mode": "BROADCAST_MODE_SYNC"
}
Modes:
| Mode | Description |
|---|---|
BROADCAST_MODE_SYNC | Wait for CheckTx |
BROADCAST_MODE_ASYNC | Return immediately |
BROADCAST_MODE_BLOCK | Wait for block (deprecated) |
Pagination
Large result sets use pagination:
GET /cosmos/staking/v1beta1/validators?pagination.limit=10&pagination.offset=0
Parameters:
| Parameter | Description |
|---|---|
pagination.limit | Max results per page |
pagination.offset | Skip first N results |
pagination.key | Base64 encoded next page key |
pagination.count_total | Include total count |
Error Responses
{
"code": 3,
"message": "account mono1abc... not found",
"details": []
}
Common codes:
| Code | Meaning |
|---|---|
| 2 | Unknown |
| 3 | Invalid argument |
| 5 | Not found |
| 11 | Out of range |
Running Your Own
Enable REST API in your node:
# app.toml
[api]
enable = true
address = "tcp://0.0.0.0:1317"
swagger = true
Access Swagger UI at: http://localhost:1317/swagger/
Related
- Cosmos gRPC - gRPC API
- EVM RPC - EVM JSON-RPC