# Integrations API

## Router API Documentation

This API provides endpoints for developers to interact with and extend the functionality of the router. Below are the main endpoints along with cURL examples, request/response formats, and detailed descriptions.

### 1. Update Proxy

**Endpoint:** `/api/update_proxy`\
**Method:** `POST`\
**Description:** Updates the proxy configuration for the specified IP addresses.

#### Request

* **Headers:**
  * `Content-Type: application/json`
* **Body:**\
  A JSON object where the keys are IP addresses and the values contain the proxy configuration:
  * `type`: Proxy type (e.g., `socks5`)
  * `server`: Proxy server address
  * `port`: Connection port
  * `username`: Login username
  * `password`: Login password

#### Example

```bash
curl --location 'http://192.168.5.1:9000/api/update_proxy' \
--header 'Content-Type: application/json' \
--data '{
    "192.168.4.253": {
        "type": "socks5",
        "server": "179.60.183.234",
        "port": 50101,
        "username": "genrouter",
        "password": "MDoFXVw5s8"
    },
    "192.168.5.104": {
        "type": "socks5",
        "server": "179.60.183.234",
        "port": 50101,
        "username": "genrouter",
        "password": "MDoFXVw5s8"
    }
}'

```

Sample Response

```
{"success": true}
```

### 2. Get Device List

**Endpoint:** `/api/devices`\
**Method:** `GET`\
**Description:** Retrieves a list of devices connected to the router along with details such as IP, MAC, hostname, connection status, and proxy configuration (if applicable).

Example

```bash
curl 'http://192.168.8.1:9000/api/devices'
```

Sample Response

```
{
    "data": [
        {
            "ip": "192.168.8.101",
            "mac": "40:c2:ba:89:c1:51",
            "hostname": "akatsuki",
            "connected": true
        },
        {
            "ip": "192.168.8.102",
            "mac": "",
            "hostname": "",
            "proxy": {
                "type": "socks5",
                "server": "179.60.183.234",
                "port": 50101,
                "username": "genrouter",
                "password": "MDoFXVw5s8",
                "udp": true
            },
            "connected": false
        }
    ]
}

```

### 3. System Information

**Endpoint:** `/api/system/info`\
**Method:** `GET`\
**Description:** Retrieves system information such as the build version, git commit, last version check time, and whether a reboot is required.

Example

```bash
curl 'http://192.168.8.1:9000/api/system/info' --insecure
```

Sample Response

```
{
    "build_version": "20250401",
    "current_version": "424319ff5b9e",
    "git_commit": "810f2d0",
    "last_version_check_time": "2025-04-01T08:14:18.39529544Z",
    "need_reboot": false,
    "newest_version": "424319ff5b9e",
    "success": true
}
```

### 4. Router Information

**Endpoint:** `/api/router/info`\
**Method:** `GET`\
**Description:** Retrieves the router configuration, including LAN and wireless settings.

Example

```bash
curl 'http://192.168.8.1:9000/api/router/info' --insecure
```

Sample Response

```
{
    "data": {
        "lan": {
            "networks": [
                {
                    "ip": "192.168.8.1",
                    "prefix_length": 24,
                    "dhcp_start": 100,
                    "dhcp_limit": 150,
                    "dhcp_lease_time": 0,
                    "device": "br-lan",
                    "ports": [
                        "eth0"
                    ],
                    "id": "lan",
                    "mac": "",
                    "country": "",
                    "brand": ""
                }
            ]
        },
        "wireless": {
            "radios": [
                {
                    "id": "radio0",
                    "band": "2g",
                    "mode": "speed",
                    "channel_id": "1",
                    "channels": [
                        {
                            "value": "auto",
                            "label": "auto"
                        },
                        {
                            "value": "1",
                            "label": "1 (2412 Mhz)"
                        },
                        {
                            "value": "2",
                            "label": "2 (2417 Mhz)"
                        },
                        {
                            "value": "3",
                            "label": "3 (2422 Mhz)"
                        },
                        {
                            "value": "4",
                            "label": "4 (2427 Mhz)"
                        },
                        {
                            "value": "5",
                            "label": "5 (2432 Mhz)"
                        },
                        {
                            "value": "6",
                            "label": "6 (2437 Mhz)"
                        },
                        {
                            "value": "7",
                            "label": "7 (2442 Mhz)"
                        },
                        {
                            "value": "8",
                            "label": "8 (2447 Mhz)"
                        },
                        {
                            "value": "9",
                            "label": "9 (2452 Mhz)"
                        },
                        {
                            "value": "10",
                            "label": "10 (2457 Mhz)"
                        },
                        {
                            "value": "11",
                            "label": "11 (2462 Mhz)"
                        }
                    ],
                    "ssids": [
                        {
                            "id": "gr_radio0_0",
                            "ssid": "GenRouter H3000",
                            "password": "",
                            "mac": "",
                            "brand": "",
                            "country": "",
                            "hidden": "",
                            "disabled": "0"
                        }
                    ]
                },
                {
                    "id": "radio1",
                    "band": "5g",
                    "mode": "speed",
                    "channel_id": "36",
                    "channels": [
                        {
                            "value": "auto",
                            "label": "auto"
                        },
                        {
                            "value": "36",
                            "label": "36 (5180 Mhz)"
                        },
                        {
                            "value": "40",
                            "label": "40 (5200 Mhz)"
                        },
                        {
                            "value": "44",
                            "label": "44 (5220 Mhz)"
                        },
                        {
                            "value": "48",
                            "label": "48 (5240 Mhz)"
                        },
                        {
                            "value": "52",
                            "label": "52 (5260 Mhz)"
                        },
                        {
                            "value": "56",
                            "label": "56 (5280 Mhz)"
                        },
                        {
                            "value": "60",
                            "label": "60 (5300 Mhz)"
                        },
                        {
                            "value": "64",
                            "label": "64 (5320 Mhz)"
                        },
                        {
                            "value": "100",
                            "label": "100 (5500 Mhz)"
                        },
                        {
                            "value": "104",
                            "label": "104 (5520 Mhz)"
                        },
                        {
                            "value": "108",
                            "label": "108 (5540 Mhz)"
                        },
                        {
                            "value": "112",
                            "label": "112 (5560 Mhz)"
                        },
                        {
                            "value": "116",
                            "label": "116 (5580 Mhz)"
                        },
                        {
                            "value": "120",
                            "label": "120 (5600 Mhz)"
                        },
                        {
                            "value": "124",
                            "label": "124 (5620 Mhz)"
                        },
                        {
                            "value": "128",
                            "label": "128 (5640 Mhz)"
                        },
                        {
                            "value": "132",
                            "label": "132 (5660 Mhz)"
                        },
                        {
                            "value": "136",
                            "label": "136 (5680 Mhz)"
                        },
                        {
                            "value": "140",
                            "label": "140 (5700 Mhz)"
                        },
                        {
                            "value": "144",
                            "label": "144 (5720 Mhz)"
                        },
                        {
                            "value": "149",
                            "label": "149 (5745 Mhz)"
                        },
                        {
                            "value": "153",
                            "label": "153 (5765 Mhz)"
                        },
                        {
                            "value": "157",
                            "label": "157 (5785 Mhz)"
                        },
                        {
                            "value": "161",
                            "label": "161 (5805 Mhz)"
                        }
                    ],
                    "ssids": null
                }
            ]
        }
    },
    "success": true
}

```

### 5. Get System Configuration

**Endpoint:** `/api/system/config`\
**Method:** `GET`\
**Description:** Retrieves the router's system configuration, including modes such as WebRTC and global proxy settings.

Example

```bash
curl 'http://192.168.8.1:9000/api/system/config' \
  --insecure
```

Sample Response

```
{
    "data": {
        "webrtcMode": 1,
        "globalProxyMode": 0,
        "globalProxy": null
    },
    "success": true
}

```

### 6. Check Network Connection

**Endpoint:** `/api/system/network`\
**Method:** `GET`\
**Description:** Checks the network connectivity of the router. A response with `"success": true` indicates that the router is connected to the network.

Example

```bash
curl 'http://192.168.8.1:9000/api/system/network' \
  --insecure
```

Sample Response

```
{"success": true}
```

### 7. Check for System Update

**Endpoint:** `/api/system/check_for_update`\
**Method:** `GET`\
**Description:** Checks if a new system update is available and provides details such as the build version, git commit, update ID, and changelog.

```bash
curl http://192.168.8.1:9000/api/system/check_for_update
```

Sample Response

```
{
    "data": {
        "build_version": "20250401",
        "git_commit": "810f2d0",
        "update_id": "424319ff5b9e",
        "changelog": ""
    },
    "success": true
}

```

### 8. Create WiFi Network

**Endpoint:** `/api/router/create_wifi`\
**Method:** `POST`\
**Description:** Creates or configures the WiFi network on the router. The request payload includes radio information and the SSIDs to be configured.

#### Request

* **Body:**\
  A JSON object with a key `data` that contains an array of configuration objects. Each object includes:
  * `id`: The radio ID (e.g., `radio0`)
  * `ssids`: An array of SSID configuration objects, each with:
    * `ssid`: WiFi network name
    * `password`: Password (can be set to `null` if not used)
    * `hidden`: Boolean indicating if the SSID is hidden
    * `disabled`: Boolean indicating if the SSID is disabled
    * `mac`, `brand`: Additional fields if applicable

Example

```bash
curl 'http://192.168.8.1:9000/api/router/create_wifi' \
  --data-raw '{"data":[{"id":"radio0","ssids":[{"ssid":"GenRouter H3000","password":null,"hidden":false,"disabled":false,"mac":"","brand":""},{"ssid":"Cahaahaah","password":"aassasas","hidden":true,"disabled":false,"mac":"","brand":"viettel"}]}]}' \
  --insecure
```

Sample Response

```
{"success": true}
```

### General Notes

* Endpoints related to system and router (e.g., `/api/system/info`, `/api/router/info`, `/api/system/config`, `/api/system/network`, `/api/system/check_for_update`, `/api/router/create_wifi`) may require the `--insecure` flag with cURL if the system is using an invalid SSL certificate.
* The examples provided can be adjusted based on your specific environment (IP addresses, ports, authentication details, etc.).
