package
2.0.0-beta.2
Repository: https://github.com/cosmos/cosmos-sdk.git
Documentation: pkg.go.dev

# README

Cosmos SDK REST API

This document describes how to use a service that exposes endpoints based on Cosmos SDK Protobuf message types. Each endpoint responds with data in JSON format.

General Description

The service allows querying the blockchain using any type of Protobuf message available in the Cosmos SDK application through HTTP POST requests. Each endpoint corresponds to a Cosmos SDK protocol message (proto), and responses are returned in JSON format.

Example

1. QueryBalanceRequest

This endpoint allows querying the balance of an account given an address and a token denomination.

  • URL: localhost:8080/cosmos.bank.v2.QueryBalanceRequest

  • Method: POST

  • Headers:

    • Content-Type: application/json
  • Body (JSON):

    {
        "address": "<ACCOUNT_ADDRESS>",
        "denom": "<TOKEN_DENOMINATION>"
    }
    
    • address: Account address on the Cosmos network.
    • denom: Token denomination (e.g., stake).
  • Request Example:

    POST localhost:8080/cosmos.bank.v2.QueryBalanceRequest
    Content-Type: application/json
    
    {
        "address": "cosmos16tms8tax3ha9exdu7x3maxrvall07yum3rdcu0",
        "denom": "stake"
    }
    
  • Response Example (JSON):

    {
        "balance": {
            "denom": "stake",
            "amount": "1000000"
        }
    }
    

    The response shows the balance of the specified token for the given account.

Using Tools

1. Using curl

To make a request using curl, you can run the following command:

curl -X POST localhost:8080/cosmos.bank.v2.QueryBalanceRequest \
  -H "Content-Type: application/json" \
  -d '{
    "address": "cosmos16tms8tax3ha9exdu7x3maxrvall07yum3rdcu0",
    "denom": "stake"
  }'

# Functions

No description provided by the author
Disable the rest server by default (default enabled).
No description provided by the author
No description provided by the author
NewWithConfigOptions creates a new REST server with the provided config options.
OverwriteDefaultConfig overwrites the default config with the new config.

# Constants

No description provided by the author
1 MB.
No description provided by the author

# Structs

Config defines configuration for the REST server.
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author