# Modules: admin

## admin\_addPeer

AddPeer requests connecting to a remote node, and also maintaining the new\
connection at all times, even reconnecting if it is lost.

### **Params (1)**

Parameters must be given *by position*.

**1:** url `string`

* Required: ✓ Yes

### **Result**

`bool`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_addPeer", "params": [<url>]}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_addPeer", "params": [<url>]}'
```

#### "Javascript Console"

```javascript
admin.addPeer(url);
```

***

## admin\_datadir

Datadir retrieves the current data directory the node is using.

### **Params (0)**

*None*

### **Result**

`string`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_datadir", "params": []}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_datadir", "params": []}'
```

#### "Javascript Console"

```javascript
admin.datadir();
```

***

## admin\_exportChain

ExportChain exports the current blockchain into a local file,\
or a range of blocks if first and last are non-nil.

### **Params (3)**

Parameters must be given *by position*.

**1:** file `string`

* Required: ✓ Yes

**2:** first `*uint64`

* Required: ✓ Yes

#### "Schema"

```scheme
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
```

#### "Raw"

```json
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}
```

**3:** last `*uint64`

* Required: ✓ Yes

#### "Schema"

```scheme
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
```

#### "Raw"

```json
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}
```

### **Result**

`bool`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_exportChain", "params": [<file>, <first>, <last>]}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_exportChain", "params": [<file>, <first>, <last>]}'
```

#### Javascript Console"

```javascript
admin.exportChain(file,first,last);
```

***

## admin\_maxPeers

MaxPeers sets the maximum peer limit for the protocol manager and the p2p server.

### **Params (1)**

Parameters must be given *by position*.

**1:** n `int`

* Required: ✓ Yes

#### "Schema"

```scheme
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
```

#### "Raw"

```json
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}
```

### **Result**

`bool`

* Required: ✓ Yes

**Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_maxPeers", "params": [<n>]}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_maxPeers", "params": [<n>]}'
```

#### "Javascript Console"

```javascript
admin.maxPeers(n);
```

***

## admin\_peerEvents

PeerEvents creates an RPC subscription which receives peer events from the\
node's p2p.Server

### **Params (0)**

*None*

### **Result**

`*rpc.Subscription`

* Required: ✓ Yes

#### "Schema"

```scheme
- description: `Subscription identifier`
- title: `subscriptionID`
- type: string
```

#### "Raw"

```json
{
    "description": "Subscription identifier",
    "title": "subscriptionID",
    "type": [
        "string"
    ]
}
```

### **Client Method Invocation Examples**

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_subscribe", "params": ["peerEvents"]}'
```

***

## admin\_removePeer

RemovePeer disconnects from a remote node if the connection exists

### **Params (1)**

Parameters must be given *by position*.

**1:** url `string`

* Required: ✓ Yes

**Result**

`bool`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_removePeer", "params": [<url>]}'
```

### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_removePeer", "params": [<url>]}'
```

### "Javascript Console"

```javascript
admin.removePeer(url);
```

***

## admin\_startHTTP

StartHTTP starts the HTTP RPC API server.

### **Params (5)**

Parameters must be given *by position*.

**1:** host `*string`

* Required: ✓ Yes

**2:** port `*int`

* Required: ✓ Yes

#### "Schema"

```scheme
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
```

#### "Raw"

```
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}
```

**3:** cors `*string`

* Required: ✓ Yes

**4:** apis `*string`

* Required: ✓ Yes

**5:** vhosts `*string`

* Required: ✓ Yes

### **Result**

`bool`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_startHTTP", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_startHTTP", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
```

#### "Javascript Console"

````
``` js
admin.startHTTP(host,port,cors,apis,vhosts);
```
````

***

## admin\_startRPC

StartRPC starts the HTTP RPC API server.\
Deprecated: use StartHTTP instead.

### **Params (5)**

Parameters must be given *by position*.

**1:** host `*string`

* Required: ✓ Yes

**2:** port `*int`

* Required: ✓ Yes

#### "Schema"

```scheme
- description: `Hex representation of the integer`
- pattern: `^0x[a-fA-F0-9]+$`
- title: `integer`
- type: string
```

#### "Raw"

```json
{
    "description": "Hex representation of the integer",
    "pattern": "^0x[a-fA-F0-9]+$",
    "title": "integer",
    "type": [
        "string"
    ]
}
```

**3:** cors `*string`

* Required: ✓ Yes

**4:** apis `*string`

* Required: ✓ Yes

**5:** vhosts `*string`

* Required: ✓ Yes

### **Result**

`bool`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_startRPC", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_startRPC", "params": [<host>, <port>, <cors>, <apis>, <vhosts>]}'
```

#### "Javascript Console"

```javascript
admin.startRPC(host,port,cors,apis,vhosts);
```

***

## admin\_stopHTTP

StopHTTP shuts down the HTTP server.

### **Params (0)**

*None*

### **Result**

`bool`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_stopHTTP", "params": []}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_stopHTTP", "params": []}'
```

#### "Javascript Console"

```javascript
admin.stopHTTP();
```

***

## admin\_stopWS

StopWS terminates all WebSocket servers.

### **Params (0)**

*None*

### **Result**

`bool`

* Required: ✓ Yes

### **Client Method Invocation Examples**

#### "Shell HTTP"

```sh
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "admin_stopWS", "params": []}'
```

#### "Shell WebSocket"

```sh
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "admin_stopWS", "params": []}'
```

#### "Javascript Console"

```javascript
admin.stopWS();
```
