The API Layer provides interfaces for querying blockchain state and submitting transactions. Akash nodes expose three types of APIs: gRPC (primary), REST (gRPC-Gateway), and CometBFT RPC.
API Architecture
+---------------------------------------------------------------+| API Layer || || +-----------------+ +-----------------+ +----------------+ || | gRPC | | REST | | CometBFT | || | (Port 9090) | | (Port 1317) | | RPC | || | | | | | (Port 26657) | || | Native Binary | | HTTP Gateway | | | || | Protocol Buf | | (gRPC-Gateway) | | Blockchain | || | Streaming | | JSON/HTTP | | Queries | || +-----------------+ +-----------------+ +----------------+ || | | | || +--------------------+--------------------+ || | |+---------------------------------------------------------------+ | Application State (Keepers & State Store)gRPC API
gRPC is the primary API for querying state and submitting transactions.
Why gRPC?
Advantages:
- High Performance - Binary protocol (Protocol Buffers)
- Type Safety - Strong typing via protobuf
- Streaming - Real-time updates
- Code Generation - Auto-generate clients
- HTTP/2 - Multiplexing, compression
Default Port: 9090
Service Types
1. Query Services - Read-only state queries 2. Msg Services - Submit transactions 3. Reflection Services - Service discovery
gRPC Query Services
Cosmos SDK Queries
Auth Module:
/cosmos.auth.v1beta1.Query/Account/cosmos.auth.v1beta1.Query/Accounts/cosmos.auth.v1beta1.Query/AccountInfo/cosmos.auth.v1beta1.Query/ParamsBank Module:
/cosmos.bank.v1beta1.Query/Balance/cosmos.bank.v1beta1.Query/AllBalances/cosmos.bank.v1beta1.Query/TotalSupply/cosmos.bank.v1beta1.Query/SupplyOf/cosmos.bank.v1beta1.Query/DenomMetadataStaking Module:
/cosmos.staking.v1beta1.Query/Validators/cosmos.staking.v1beta1.Query/Validator/cosmos.staking.v1beta1.Query/Delegation/cosmos.staking.v1beta1.Query/Delegations/cosmos.staking.v1beta1.Query/UnbondingDelegation/cosmos.staking.v1beta1.Query/PoolDistribution Module:
/cosmos.distribution.v1beta1.Query/Rewards/cosmos.distribution.v1beta1.Query/DelegationTotalRewards/cosmos.distribution.v1beta1.Query/ValidatorCommission/cosmos.distribution.v1beta1.Query/CommunityPoolGov Module:
/cosmos.gov.v1.Query/Proposal/cosmos.gov.v1.Query/Proposals/cosmos.gov.v1.Query/Vote/cosmos.gov.v1.Query/Votes/cosmos.gov.v1.Query/Params/cosmos.gov.v1.Query/DepositsAkash Module Queries
Deployment Module:
/akash.deployment.v1.Query/Deployments/akash.deployment.v1.Query/Deployment/akash.deployment.v1.Query/GroupMarket Module:
/akash.market.v1.Query/Orders/akash.market.v1.Query/Order/akash.market.v1.Query/Bids/akash.market.v1.Query/Bid/akash.market.v1.Query/Leases/akash.market.v1.Query/LeaseProvider Module:
/akash.provider.v1.Query/Providers/akash.provider.v1.Query/ProviderAudit Module:
/akash.audit.v1.Query/AllProvidersAttributes/akash.audit.v1.Query/ProviderAttributes/akash.audit.v1.Query/ProviderAuditorAttributes/akash.audit.v1.Query/AuditorAttributesCert Module:
/akash.cert.v1.Query/CertificatesEscrow Module:
/akash.escrow.v1.Query/Accounts/akash.escrow.v1.Query/PaymentsgRPC Client Examples
Query Providers
# Using grpcurl (install: go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest)
grpcurl -plaintext localhost:9090 \
akash.provider.v1.Query/ProvidersQuery Specific Deployment
grpcurl -plaintext \
-d '{
"id": {
"owner": "akash1...",
"dseq": "123"
}
}' \
localhost:9090 \
akash.deployment.v1.Query/DeploymentREST API (gRPC-Gateway)
REST API is automatically generated from gRPC services using gRPC-Gateway.
Default Port: 1317
Enable REST API:
[api]enable = trueaddress = "tcp://0.0.0.0:1317"REST Endpoints
Format:
GET /akash/{module}/{version}/{resource}POST /cosmos/tx/v1beta1/txsCosmos SDK REST Endpoints
Auth:
GET /cosmos/auth/v1beta1/accounts/{address}GET /cosmos/auth/v1beta1/accountsBank:
GET /cosmos/bank/v1beta1/balances/{address}GET /cosmos/bank/v1beta1/balances/{address}/by_denomGET /cosmos/bank/v1beta1/supplyStaking:
GET /cosmos/staking/v1beta1/validatorsGET /cosmos/staking/v1beta1/validators/{validator_addr}GET /cosmos/staking/v1beta1/delegations/{delegator_addr}GET /cosmos/staking/v1beta1/validators/{validator_addr}/delegationsGov:
GET /cosmos/gov/v1/proposalsGET /cosmos/gov/v1/proposals/{proposal_id}GET /cosmos/gov/v1/proposals/{proposal_id}/votesGET /cosmos/gov/v1/proposals/{proposal_id}/depositsAkash REST Endpoints
Deployment:
GET /akash/deployment/v1/deployments/listGET /akash/deployment/v1/deployments/info ?id.owner={owner}&id.dseq={dseq}Market:
GET /akash/market/v1/orders/listGET /akash/market/v1/orders/info ?id.owner={owner}&id.dseq={dseq}&id.gseq={gseq}&id.oseq={oseq}
GET /akash/market/v1/bids/listGET /akash/market/v1/leases/listProvider:
GET /akash/provider/v1/providersGET /akash/provider/v1/providers/{owner}Audit:
GET /akash/audit/v1/attributes/listREST Examples
Query Account Balance
curl http://localhost:1317/cosmos/bank/v1beta1/balances/akash1...Response:
{ "balances": [ { "denom": "uakt", "amount": "1000000000" } ], "pagination": { "next_key": null, "total": "1" }}Query Providers
curl "http://localhost:1317/akash/provider/v1/providers"Submit Transactions
Via gRPC
1. Build transaction:
msg := &deploymenttypes.MsgCreateDeployment{ Id: deploymenttypes.DeploymentID{ Owner: owner, Dseq: dseq, }, Groups: groups, Version: version, Deposit: deposit,}
txBuilder := txConfig.NewTxBuilder()txBuilder.SetMsgs(msg)txBuilder.SetGasLimit(200000)txBuilder.SetFeeAmount(sdk.NewCoins( sdk.NewCoin("uakt", sdk.NewInt(5000)),))2. Sign transaction:
signerData := authsigning.SignerData{ ChainID: chainID, AccountNumber: accNum, Sequence: seq,}
sigV2, err := tx.SignWithPrivKey( txConfig.SignModeHandler(), signerData, txBuilder, privKey, txConfig, seq,)3. Broadcast:
txBytes, err := txConfig.TxEncoder()(txBuilder.GetTx())
broadcastReq := &txtypes.BroadcastTxRequest{ TxBytes: txBytes, Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC,}
client := txtypes.NewServiceClient(conn)res, err := client.BroadcastTx(ctx, broadcastReq)Via REST
Endpoint:
POST /cosmos/tx/v1beta1/txsRequest body:
{ "tx_bytes": "base64_encoded_tx", "mode": "BROADCAST_MODE_SYNC"}Broadcast modes:
BROADCAST_MODE_SYNC- Wait for CheckTxBROADCAST_MODE_ASYNC- Return immediatelyBROADCAST_MODE_BLOCK- Wait for block inclusion (deprecated)
CometBFT RPC
Low-level blockchain queries via CometBFT RPC.
Default Port: 26657
Enable RPC:
[rpc]laddr = "tcp://0.0.0.0:26657"Common RPC Endpoints
Node Status:
GET /statusResponse:
{ "node_info": { "protocol_version": {...}, "id": "node_id", "network": "akashnet-2", "version": "0.38.0" }, "sync_info": { "latest_block_hash": "ABC123...", "latest_block_height": "12345678", "latest_block_time": "2024-01-01T00:00:00Z", "catching_up": false }, "validator_info": { "address": "validator_address", "pub_key": {...}, "voting_power": "1000000" }}Get Block:
GET /block?height=12345Get Block by Hash:
GET /block_by_hash?hash=0x...Get Latest Block:
GET /blockGet Blockchain Info:
GET /blockchain?minHeight=1&maxHeight=100Get Transaction:
GET /tx?hash=0x...&prove=trueSearch Transactions:
GET /tx_search?query="tx.height>1000"&prove=falseGet Validators:
GET /validators?height=12345Get Consensus State:
GET /consensus_stateGet Net Info:
GET /net_infoGet Genesis:
GET /genesisRPC Examples
Check Node Status
curl http://localhost:26657/status | jqGet Block by Height
curl "http://localhost:26657/block?height=12345" | jqWebSocket Subscriptions
Subscribe to real-time blockchain events.
Endpoint:
ws://localhost:26657/websocketSubscribe to Events
New blocks:
{ "jsonrpc": "2.0", "method": "subscribe", "params": { "query": "tm.event='NewBlock'" }, "id": 1}New transactions:
{ "jsonrpc": "2.0", "method": "subscribe", "params": { "query": "tm.event='Tx'" }, "id": 2}Custom events:
{ "jsonrpc": "2.0", "method": "subscribe", "params": { "query": "akash.v1.EventLeaseCreated.id.owner='akash1...'" }, "id": 3}WebSocket Example
# Using websocat (install: cargo install websocat)
echo '{"jsonrpc":"2.0","method":"subscribe","params":{"query":"tm.event='\''NewBlock'\''"},"id":1}' | \
websocat ws://localhost:26657/websocketAPI Configuration
gRPC Configuration
app.toml:
[grpc]enable = trueaddress = "0.0.0.0:9090"REST Configuration
app.toml:
[api]enable = trueaddress = "tcp://0.0.0.0:1317"swagger = trueenabled-unsafe-cors = falseRPC Configuration
config.toml:
[rpc]laddr = "tcp://0.0.0.0:26657"
# Maximum number of simultaneous connectionsmax_open_connections = 900
# Maximum number of subscription clientsmax_subscription_clients = 100
# CORS allowed originscors_allowed_origins = []Security Considerations
Production API Setup
1. Use Reverse Proxy
server { listen 443 ssl; server_name api.example.com;
location / { proxy_pass http://localhost:1317; }}2. Rate Limiting
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
location / { limit_req zone=api burst=20; proxy_pass http://localhost:1317;}3. Authentication
Add API keys or OAuth for public endpoints.
4. CORS Configuration
[api]enabled-unsafe-cors = false # Disable in production5. Firewall Rules
# Only allow from specific IPsufw allow from 1.2.3.4 to any port 9090ufw allow from 1.2.3.4 to any port 1317Public RPC Nodes
Trusted community RPC nodes:
https://rpc.akashnet.net:443https://rpc.akash.forbole.com:443https://rpc-akash.ecostake.com:443https://akash-rpc.polkachu.com:443https://akash.c29r3.xyz:443/rpcLatest list:
curl https://raw.githubusercontent.com/akash-network/net/main/mainnet/rpc-nodes.txtSwagger/OpenAPI Documentation
Enable Swagger UI:
[api]swagger = trueAccess Swagger:
http://localhost:1317/swagger/OpenAPI spec: