Skip to content

Commit

Permalink
Merge pull request #1228 from ainblockchain/feature/platfowner/feature
Browse files Browse the repository at this point in the history
Add network api to json_rpc_api.md file
  • Loading branch information
platfowner authored Jan 8, 2024
2 parents 1cdb20e + bf80b2b commit d708705
Showing 1 changed file with 151 additions and 0 deletions.
151 changes: 151 additions & 0 deletions JSON_RPC_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1128,4 +1128,155 @@ Response
}
```

---

## Network API

### net_listening

Returns whether the node is listening for network connections.

**Parameters**

None.

**Returns**

`Boolean` - true is the node is listening for connections; otherwise, false.

**Example**

Request
```
curl -X POST --data '{"jsonrpc":"2.0","id":1,"method":"net_listening"}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":true
}
```

### net_nodeInfo

Returns the node's information.

**Parameters**

None.

**Returns**

`Object` - the object containing node's information.

**Example**

Request
```
curl -X POST --data '{"jsonrpc":"2.0","id":1,"method":"net_nodeInfo"}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":{
"name":"comcom_node",
"location":"KOR",
"version":"1.0.0"
}
}
```

### net_peerCount

Returns the number of peers the node is connected to.

**Parameters**

None.

**Returns**

`Number` - number of peers.

**Example**

Request
```
curl -X POST --data '{"jsonrpc":"2.0","id":1,"method":"net_peerCount"}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":7
}
```

### net_syncing

Returns whether the node is syncing with the network or not.

**Parameters**

None.

**Returns**

`Boolean` - true if the node is syncing, false otherwise.

**Example**

Request
```
curl -X POST --data '{"jsonrpc":"2.0","id":1,"method":"net_syncing"}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":true
}
```

### net_id

Returns the network id.

**Parameters**

None.

**Returns**

`Number` - the network id.

- 0: main network
- 1: test network

**Example**

Request
```
curl -X POST --data '{"jsonrpc":"2.0","id":1,"method":"net_id"}'
```

Response
```
{
"jsonrpc":"2.0",
"id":1,
"result":0
}
```

---

0 comments on commit d708705

Please sign in to comment.