# 基础API端点 (Basic API Endpoints)



Here are some basic API Endpoints that might be helpful when configuring your node or validator.

以下是一些在配置节点或验证者时可能会有帮助的基本 API 端点。

For the examples below, it is assumed that the commands are run alongside the node / validator process. However, it is possible to send these requests to a remote node:

对于下面的示例，假设命令与节点/验证者进程一起运行。但是，可以将这些请求发送到远程节点：

* For CLI calls, you may specify a remote node with the `--node` flag\
  对于 CLI 调用，您可以使用 `--node` 标志指定远程节点
* For REST calls, you can replace `localhost` with the IP address of the remote node 对于 REST 调用，您可以将 `localhost` 替换为远程节点的 IP 地址

## 获取节点信息 (Get Node status)

### CLI

```
> seid status | jq -r ".NodeInfo"
{
  "protocol_version": {
    "p2p": "8",
    "block": "11",
    "app": "0"
  },
  "id": "c3beb6d42f10311fd453029cb3ee6ac08880d522",
  "listen_addr": "tcp://0.0.0.0:26656",
  "network": "sei-testnet-1",
  "version": "0.34.15",
  "channels": "40202122233038606100",
  "moniker": "phils validator",
  "other": {
    "tx_index": "on",
    "rpc_address": "tcp://127.0.0.1:26657"
  }
```

### REST

```
> curl localhost:1317/cosmos/base/tendermint/v1beta1/node_info  | jq -r ".default_node_info"
{
  "protocol_version": {
    "p2p": "8",
    "block": "11",
    "app": "0"
  },
  "default_node_id": "c3beb6d42f10311fd453029cb3ee6ac08880d522",
  "listen_addr": "tcp://0.0.0.0:26656",
  "network": "sei-testnet-1",
  "version": "0.34.15",
  "channels": "QCAhIiMwOGBhAA==",
  "moniker": "phils validator",
  "other": {
    "tx_index": "on",
    "rpc_address": "tcp://127.0.0.1:26657"
  }
}
```

## 获得节点id (Get Node Id)

### 命令行 CLI

```
> seid tendermint show-node-id
89e8fdd427a056fb7b4f5da2d58a4b688feb4b74
```

### REST

```
> curl localhost:1317/cosmos/base/tendermint/v1beta1/node_info | jq -r ".default_node_info.default_node_id
89e8fdd427a056fb7b4f5da2d58a4b688feb4b74
```

## 获取同步状态 (Get Sync Status)

### 命令行 CLI

```
> seid status | jq -r ".SyncInfo.catching_up"
false
```

### REST

```
> curl localhost:1317/cosmos/base/tendermint/v1beta1/syncing
{
  "syncing": false
}
```

## 获得最新区块 (Get Latest Block)

### 命令行 CLI

```
> seid query block | jq
{
  "block_id": {
    "hash": "92B93642DCCECFBDFEAE972C67294CF1B3574FAF55F3B24E218990CC4EE28B0A",
    "parts": {
      "total": 1,
      "hash": "5FBD2E43F3A3F6DBD9C9E2021B1505DF3AC74841F7207F479E701FF0726E0EF3"
    }
  },
  "block": {
    "header": {
      "version": {
        "block": "11"
      },
...
```

### REST

```
> curl localhost:1317/cosmos/base/tendermint/v1beta1/blocks/latest
{
  "block_id": {
    "hash": "krk2QtzOz73+rpcsZylM8bNXT69V87JOIYmQzE7iiwo=",
    "part_set_header": {
      "total": 1,
      "hash": "X70uQ/Oj9tvZyeICGxUF3zrHSEH3IH9HnnAf8HJuDvM="
    }
  },
  "block": {
    "header": {
      "version": {
        "block": "11",
...
```

## 查询银行余额 (Query Bank Balances)

### 命令行 CLI

```
> seid query bank balances $ACCOUNT_ADDRESS
balances:
- amount: "29999999999995999900"
  denom: ust
pagination:
  next_key: null
  total: "0"
```

### REST

```
> curl localhost:1317/bank/balances/$ACCOUNT_ADDRESS
{"height":"4028","result":[
  {
    "denom": "ust",
    "amount": "29999999999995999900"
  }
]}
```

## 获取验证者 (Get Validators)

### 命令行 CLI

```
> seid query tendermint-validator-set
block_height: "3472"
total: "2"
validators:
- address: cosmosvalcons1xrn3ejn56chrv26mfk9vaztef63zptkmygmdxf
  proposer_priority: "39374999999767"
  pub_key:
    type: tendermint/PubKeyEd25519
    value: Cf46GgHIjqEdk5ZeHux/PTWEmWUWnxTFeyJxIzwoxSA=
  voting_power: "70000000000000"
```

### REST

```
> curl localhost:1317/cosmos/base/tendermint/v1beta1/validatorsets/latest
{
  "block_height": "4156",
  "validators": [
    {
      "address": "cosmosvalcons1xrn3ejn56chrv26mfk9vaztef63zptkmygmdxf",
      "pub_key": {
        "@type": "/cosmos.crypto.ed25519.PubKey",
        "key": "Cf46GgHIjqEdk5ZeHux/PTWEmWUWnxTFeyJxIzwoxSA="
      },
      "voting_power": "70000000000000",
      "proposer_priority": "42656249998811"
    },
```
