### Request Example for Fetching Business List Source: https://help.niulinkcloud.cn/openapi/common/node_customer_list Example of an HTTP GET request to the /v1/customers endpoint, demonstrating how to pass query parameters for filtering. ```HTTP http://niulinkcloud-example/v1/customers?externalName=业务T&openId=1 ``` -------------------------------- ### Get All Node Status API Request Example Source: https://help.niulinkcloud.cn/openapi/smallbox/query/node_list_status Example of an HTTP GET request to the /v1/ant/status endpoint. This request demonstrates how to include the Authorization header for authentication and optional query parameters like 'macs', 'remark', 'page', and 'limit' to filter and paginate the results. ```bash GET /v1/ant/status?macs=00:11:22:33:44:55&remark=test&page=1&limit=100 HTTP/1.1 Host: api.niulinkcloud.cn Authorization: Bearer YOUR_ACCESS_TOKEN ``` -------------------------------- ### Get SLA Details - Request Example Source: https://help.niulinkcloud.cn/openapi/niulink/bill/sla_info Example of an HTTP GET request to the `/v1/nodes/bill/sla` endpoint. It includes necessary headers like Authorization and query parameters such as nodeIds, start, and end times. The endpoint retrieves SLA and billing information for specified nodes and time ranges. ```http GET /v1/nodes/bill/sla?nodeIds=string&start=int&end=int HTTP/1.1 Host: api.niulink.com Authorization: Bearer ``` -------------------------------- ### Channel Customer List API Request Example (HTTP) Source: https://help.niulinkcloud.cn/openapi/common/channel/get_subchannel_list An example HTTP GET request to the `/v1/subchannel/list` endpoint. This demonstrates how to query channel customers with specific parameters like page number, page size, and signState. Note that the Authorization header is required for authentication but is omitted in this example for brevity. ```http GET /v1/subchannel/list?page=1&size=20&signState=0 HTTP/1.1 Host: niulinkcloud-example Authorization: Bearer YOUR_TOKEN ``` -------------------------------- ### Get SLA Details Request Example Source: https://help.niulinkcloud.cn/openapi/smallbox/bill/sla_info This code snippet demonstrates how to make a GET request to the /v1/ant/bill/sla endpoint to retrieve SLA details. It includes required parameters like Authorization token, start and end timestamps, and optional nodeIds. ```http GET /v1/ant/bill/sla?nodeIds=node1,node2&start=1658803200000&end=1658976000000 HTTP/1.1 Host: api.niulinkcloud.cn Authorization: Bearer YOUR_TOKEN ``` -------------------------------- ### GET /v1/vendorclaimablebw Source: https://help.niulinkcloud.cn/openapi/demo/java Retrieves information about vendor claimable bandwidth based on specified criteria. ```APIDOC ## GET /v1/vendorclaimablebw ### Description Retrieves information about vendor claimable bandwidth. This endpoint allows filtering by province, ISP, bandwidth, and NAT type. ### Method GET ### Endpoint `https://api.niulinkcloud.com/v1/vendorclaimablebw` ### Parameters #### Query Parameters - **province** (string) - Optional - The province to filter by. - **isp** (string) - Optional - The Internet Service Provider to filter by. - **usbw** (string) - Optional - The upstream bandwidth. - **bwNum** (string) - Optional - The number of bandwidth units. - **natType** (string) - Optional - The NAT type (e.g., "public"). - **dialType** (string) - Optional - The dial-up type (e.g., "staticNetSingle"). ### Request Example ``` GET https://api.niulinkcloud.com/v1/vendorclaimablebw?province=江苏&isp=移动&usbw=1000&bwNum=5&natType=public&dialType=staticNetSingle ``` ### Response #### Success Response (200) - **data** (object) - Contains bandwidth information. - **list** (array) - List of available bandwidth options. - **bw** (integer) - Bandwidth value. - **bwName** (string) - Name of the bandwidth option. - **isp** (string) - Internet Service Provider. - **ispName** (string) - Name of the ISP. - **ispType** (integer) - Type of ISP. - **ispTypeShow** (string) - Display name for ISP type. - **province** (string) - Province. - **provinceName** (string) - Display name for province. - **type** (integer) - Type of bandwidth. - **typeName** (string) - Display name for bandwidth type. #### Response Example ```json { "code": 200, "data": { "list": [ { "bw": 1000, "bwName": "1Gbps", "isp": "unicom", "ispName": "中国联通", "ispType": 2, "ispTypeShow": "联通", "province": "320000", "provinceName": "江苏省", "type": 1, "typeName": "上行" } ] }, "message": "成功" } ``` ``` -------------------------------- ### Node Brief Info Query - HTTP Request Example Source: https://help.niulinkcloud.cn/openapi/smallbox/query/ant_simple_info This snippet demonstrates how to query the brief information of a node using an HTTP GET request. It includes the necessary path parameters and headers for authentication and content type. The response provides key details about the node. ```http GET /v1/ant/dddf7b5cfff0b16d1dda6932d414ffbb14/briefInfo HTTP/1.1 Host: api.niulinkcloud.cn Authorization: Bearer YOUR_TOKEN Content-Type: application/json ``` -------------------------------- ### Batch Get Node Bandwidth Info Request Example (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_batch_stats This is an example of a JSON request payload for the batch node bandwidth information endpoint. It specifies the node IDs, desired granularity, and the time range for the data retrieval. Ensure the 'Authorization' header is included in your actual API call. ```json { "nodeIds": ["xx"], "granularity": "hour", "start": "202502241000", "end": "202502250000" } ``` -------------------------------- ### Get Node Disk Info Request Example Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_disk_info Example of an HTTP GET request to retrieve disk information for a node using its ID. The request requires an 'Authorization' header for authentication and optionally accepts 'nodeIds' or 'macs' as query parameters. ```http GET /v1/nodes/diskinfo?nodeIds=5f1e9dc7f9537d6b370xx010 HTTP/1.1 Host: niulinkcloud-example Authorization: Bearer YOUR_TOKEN ``` -------------------------------- ### Java: Perform Authenticated GET Request to NiuLink OpenAPI Source: https://help.niulinkcloud.cn/openapi/demo/java This Java code demonstrates how to make an authenticated GET request to the NiuLink Cloud OpenAPI. It requires the `qiniu-java-sdk` and `okhttp3` libraries. The function constructs the URL with query parameters, generates an authorization header using AK/SK, and executes the request using OkHttp. ```java package demo; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; import java.util.Set; import okhttp3.*; import com.qiniu.util.Json; import com.qiniu.util.StringUtils; import com.qiniu.util.Auth; /** * 域名: api.niulinkcloud.com * * maven坐标 * * com.qiniu * qiniu-java-sdk * 7.15.0 * * * * com.squareup.okhttp3 * okhttp * 5.0.0-alpha.11 * */ public class JavaDemo { public static String ak = "你的ak"; public static String sk = "你的sk"; public static final String QINIU_AUTHORIZATION_PREFIX = "Qiniu "; public static void main(String[] args) throws Exception { get(); post(); } public static void get() throws Exception { Map reqMap = new HashMap<>(); reqMap.put("province", "江苏"); reqMap.put("isp", "移动"); reqMap.put("usbw", "1000"); reqMap.put("bwNum", "5"); reqMap.put("natType", "public"); reqMap.put("dialType", "staticNetSingle"); String url = "https://api.niulinkcloud.com/v1/vendorclaimablebw?" + buildQueryParam(reqMap); Auth auth = Auth.create(ak, sk); String authorization = QINIU_AUTHORIZATION_PREFIX + auth.signQiniuAuthorization(url, "GET", (byte[])null, (String)null); OkHttpClient client = new OkHttpClient.Builder().build(); Request request = new Request.Builder() .header("Authorization", authorization) .url(url) .get() .build(); Call call = client.newCall(request); String resp = call.execute().body().string(); System.out.println(resp); } public static void post() throws Exception { // 接口的完整请求url : 域名+path String url = "https://api.niulinkcloud.com/v1/nodes/stats"; // 组装接口逻辑处理的请求参数 Map bodyMap = new HashMap<>(); bodyMap.put("nodeIDs", new String[]{"你的节点ID"}); bodyMap.put("start", "2024-03-26"); bodyMap.put("end", "2024-03-27"); String reqJsonData = Json.encode(bodyMap); // 具体签名 Auth auth = Auth.create(ak, sk); String authorization = QINIU_AUTHORIZATION_PREFIX + auth.signQiniuAuthorization(url, "POST", StringUtils.utf8Bytes(reqJsonData), "application/json"); RequestBody reqBody = RequestBody.create(StringUtils.utf8Bytes(reqJsonData)); Request request = new Request.Builder() .header("Authorization", authorization) .header("Content-Type", "application/json") .url(url) .post(reqBody) .build(); OkHttpClient client = new OkHttpClient.Builder().build(); Call call = client.newCall(request); String resp = call.execute().body().string(); System.out.println(resp); } public static String buildQueryParam(Map map) throws Exception { String result = ""; Set set = map.keySet(); for (String key : set) { result += key + "=" + URLEncoder.encode(map.get(key), "UTF-8") + "&"; } return result.substring(0, result.length() - 1); } } ``` -------------------------------- ### Node Disk Information Response Example (Success) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_disk_info Example of a successful JSON response (HTTP 200) containing disk information for nodes. It includes details for each disk, such as its name, SN, type, size, usage, IOPS, and measurement data. ```json { "items": [ { "nodeId": "5f1e9dc7f9537d6b370xx010", "diskInfos": [ { "diskName": "dev1", "sn": "123456", "isSystem": true, "type": "HDD", "size": 119, "usage": 10, "wIops": 100, "rIops": 100, "diskMeasureInfo": { "measureCost": 3600, "startTime": "2024-02-26 17:02:44", "state": "taskComplete" }, "occupantStatus": true } ] } ] } ``` -------------------------------- ### Get SLA Details - Successful Response Example Source: https://help.niulinkcloud.cn/openapi/niulink/bill/sla_info Example of a successful (HTTP 200) JSON response from the `/v1/nodes/bill/sla` endpoint. It includes `slaDetails` mapping node IDs to their SLA data and `billingInfos` indicating the billing status for each day within the queried range. SLA data may be unreliable on days marked as 'billing in progress'. ```json { "slaDetails": { "002a3e275fb274a9795034643548d322": [ { "day": "2022-07-27" }, { "day": "2022-07-28" } ], "002d8da247673d3f17996ac87433bd81": [ { "day": "2022-07-27" } ] }, "billingInfos": [ { "day": "2022-07-27", "isBilling": false }, { "day": "2022-07-28", "isBilling": true } ] } ``` -------------------------------- ### PHP API Request Examples with Authentication Source: https://help.niulinkcloud.cn/openapi/demo/php This PHP code demonstrates how to interact with the NiuLink Cloud API. It includes functions for making GET and POST requests, handling responses, and generating authentication tokens using provided AK and SK. It requires the cURL extension to be enabled. ```php '河南', 'isp' => '移动', 'usbw' => '1024', 'bwNum' => '5', 'natType' => 'public', 'dialType' => 'serverDial' ]; $url = $api.'?'.http_build_query($query); // 2、构建http header $token = get_token($url,"GET"); $header = array( "Authorization: $token", "Content-Type: $contentType" ); // 3、发起http请求 $res = do_curl($url, $header, "GET", NULL); print_r($res); } // post请求:用/v1/nodes/stats接口作为demo function post(){ // 1、组装htt url $api = HOST."/v1/nodes/stats"; // 2、构建http request body $nodeIDs = [ '你的节点ID值' ]; $body = [ 'nodeIDs' => json_encode($nodeIDs), 'start' => '2024-12-12', 'end' => '2024-12-13', ]; // 3、构建http header $contentType = 'application/json'; $token = get_token($api,"POST", $contentType, $body); $header = array( "Authorization: $token", "Content-Type: $contentType" ); // 4、发起http请求 $res = do_curl($api, $header, "POST", $body); print_r($res); } function do_curl($url, $header, $method, $data = NULL) { // 创建curl会话的句柄 $curl = curl_init(); // 设置 http url curl_setopt($curl, CURLOPT_URL, $url); // 设置 http timeout,单位为秒 curl_setopt($curl, CURLOPT_TIMEOUT, 300); if ($method == "POST") { curl_setopt($curl, CURLOPT_POST, 1); } else if ($method == "PUT" || $method == "DELETE") { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); } // 如果$data存在且非空的情况下,设置请求的body数据 if ($data) { if (is_array($data)) { $data = json_encode($data); } curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } // 设置 http header curl_setopt($curl, CURLOPT_HTTPHEADER, $header); // 当设置为 true 或 1 时,curl_exec() 将返回请求的响应数据,而不是直接输出 // 当设置为 false 或 0 时,curl_exec() 将直接输出响应数据,而不返回 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 发起http请求 $res = curl_exec($curl); // 获取http status code $http_code = curl_getinfo($curl)['http_code']; switch ($http_code){ case 200: return ['code'=>1,'msg'=>'操作成功','data'=>json_decode($res,true)]; break; case 400: case 500: return json_decode($res,true); break; } curl_close($curl); return ['code'=>0,'msg'=>'未知错误','data'=>[]]; } // 获取签名token function get_token($url, $method, $contentType='', $body=[]) { // 解析url:url通常由域名、path、queryParam组成 $urlItems = parse_url($url); // 获取path $path = ''; if (array_key_exists('path', $urlItems)) { $path = $urlItems['path']; } // 获取查询参数 $query = ''; if (array_key_exists('query', $urlItems)) { $query = '?' . $urlItems['query']; } if ($method == "GET") { $data = $path; if ($query) { $data .= $query; } $data .= "\n"; } else { $host = $urlItems['host']; if (isset($urlItems['port'])) { $port = $urlItems['port']; } else { $port = ''; } // 1、拼接请求方法、path $data = $method . ' ' . $path; // 2、拼接queryParam if (!empty($query)) { $data .= '?' . $query; } // 3、拼接host $data .= "\nHost: " . $host; // 4、拼接端口 if (!empty($port)) { $data .= ":" . $port; } // 5、拼接contentType if (!empty($contentType)) { $data .= "\nContent-Type: " . $contentType; } // 6、固定拼接\n\n $data .= "\n\n"; // 7、最后拼接body if (!empty($body)) { $data .= json_encode($body); } } // 使用sha1进行签名 $hmac = hash_hmac('sha1', $data, SK, true); $prefix = 'Qiniu '; if ($method == 'GET') { $prefix = 'QBox '; } // str_replace 函数可以用来替换字符串中的字符 // 使用base64_encode进行编码时,得到一个使用 base64字符集的字符串,该字符集包括字母 A-Z、a-z、数字 0-9,以及 '+' 和 '/' 字符。 // 为满足URL安全的要求或避免在URL中出现特殊字符,需要将结果中的'+'和'/'字符替换为其他字符'-' 和'_' $find = array('+', '/'); $replace = array('-', '_'); return $prefix . AK . ':' . str_replace($find, $replace, base64_encode($hmac)); } ?> ``` -------------------------------- ### Node Registration Response Example Source: https://help.niulinkcloud.cn/openapi/niulink/access/submit This is an example of a JSON response for a successful node registration request (HTTP 200 OK). It also shows an example of an error response structure for abnormal requests (HTTP 4xx/5xx). ```json 正常请求: http code 200 OK 异常请求: http code 4xx/5xx { "code": 4000001, "desc": "" } ``` -------------------------------- ### Python NiuLink Cloud API Authentication and Request Examples Source: https://help.niulinkcloud.cn/openapi/demo/python This Python code demonstrates how to authenticate with the NiuLink Cloud API using HMAC-SHA1 and make GET and POST requests. It includes classes for handling authentication signatures and preparing request data. Ensure you replace placeholder 'ak' and 'sk' with your actual API credentials. ```python #!/usr/bin/python3 # -*- coding: UTF-8 -*- import hmac, base64, hashlib, requests, json import time # auth class Api_Auth(object): def __init__(self): # replace following params with your ak sk self.ak = 'ak' self.sk = bytes('sk', encoding='utf-8') self.host = "api.niulinkcloud.com" def getSignKey(self, data): sign = hmac.new(self.sk, data, hashlib.sha1).digest() token = self.ak + ":" + base64.urlsafe_b64encode(sign).decode("utf-8") return "Qiniu " + token def getRequestData(self, method, path, queryStr="", bodyStr="", contentType="application/json"): data = method+" "+path if queryStr != "": data += "?"+queryStr data += "\nHost: "+self.host if bodyStr != "": data += "\nContent-Type: " + contentType data += "\n\n" if bodyStr != "" and bodyStr != "application/octet-stream": data += bodyStr return data # get status class Api_Data(object): # use /v1/nodes/status as an example of GET api def get_data(self): url = 'https://api.niulinkcloud.com/v1/nodes/status' path = '/v1/nodes/status' data = Api_Auth().getRequestData("GET", path, "", "") signkey = Api_Auth().getSignKey(data.encode('utf-8')) headers = { 'Authorization': signkey, } response = requests.get(url, headers=headers, data='') return response.content.decode() # use /v1/nodes/:nodeId/submit as an example of POST api, path is like '/v1/nodes/aaa/submit' # PUT DELETE PATCH api can refer to this api def post_data(self, path, jsonData): api = Api_Auth() data = Api_Auth().getRequestData("POST", path, "", json.dumps(jsonData)) signkey = Api_Auth().getSignKey(data.encode('utf-8')) headers = { 'Authorization': signkey, 'Content-Type': 'application/json', } # print(signkey) url = 'https://'+api.host+path response = requests.post(url, headers=headers, data=json.dumps(jsonData)) return response.content.decode() print(Api_Data().get_data()) # 节点id为aaa的专线节点提交 submitData = {"province":"浙江","city":"杭州","isp":"电信","usbw":1000,"bwNum":1,"natType":"public","dialType":"staticNetSingle"} print(Api_Data().post_data('/v1/nodes/aaa/submit',submitData)) ``` -------------------------------- ### Node Status Response Example (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_list_status This JSON example illustrates the structure of a successful response when fetching node status information from the NiuLink Cloud API. It includes an 'items' array containing detailed information for each node, such as nodeID, stage, status, and remark. ```JSON { "items": [ { "nodeID": "5f1e9dc7f9537d6b370xx010", "stage": "audit", "status": "online", "netBenchStatus": "done", "remark": "remark", "vendorSuggestOpenIDs": [1001,1002], "vendorSuggestCustomerNames": ["短视频A","短视频B"] } ] } ``` -------------------------------- ### Node Brief Info Query - JSON Response Example Source: https://help.niulinkcloud.cn/openapi/smallbox/query/ant_simple_info This snippet shows a successful JSON response when querying for a node's brief information. It includes the node's ID, vendor ID, current stage, type, serial number, CPU architecture, and operating system. Error responses will contain a 'code' and 'desc' field. ```json { "nodeId": "dddf7b5cfff0b16d1dda6932d414ffbb14", "vendorId": 1, "stage": "inService", "nodeType": "smallBox", "sn": "210235A2QUH214000052", "arch": "arm64", "os": "android" } ``` -------------------------------- ### Go: Make GET Request to NiuLink Cloud API Source: https://help.niulinkcloud.cn/openapi/demo/go This Go code demonstrates how to make a GET request to the NiuLink Cloud API endpoint 'https://api.niulinkcloud.com/v1/vendorclaimablebw'. It shows how to construct URL parameters, sign the request using Qiniu's auth SDK, and handle the HTTP response. Dependencies include 'net/http', 'net/url', and 'github.com/qiniu/go-sdk/v7/auth'. ```go package main import ( "fmt" "io/ioutil" "net/http" "net/url" "github.com/qiniu/go-sdk/v7/auth" ) const ak = "你的ak" const sk = "你的sk" func get() { params := url.Values{} params.Add("province", "江苏") params.Add("isp", "移动") params.Add("usbw", fmt.Sprint(1000)) params.Add("bwNum", fmt.Sprint(5)) params.Add("natType", "public") params.Add("dialType", "staticNetSingle") reqUrl := "https://api.niulinkcloud.com/v1/vendorclaimablebw" reqUrl = fmt.Sprintf("%s?%s", reqUrl, params.Encode()) req, err := http.NewRequest("GET", reqUrl, nil) if err != nil { return } // 设置Content-Type必须在调用SignRequestV2方法之前,因为Content-Type也需要参与签名 req.Header.Set("Content-Type", "application/json") token, err := auth.New(ak, sk).SignRequestV2(req) if err != nil { return } req.Header.Set("Authorization", "Qiniu "+token) httpCli := &http.Client{} httpResp, err := httpCli.Do(req) if err != nil { return } respBody, err := ioutil.ReadAll(httpResp.Body) defer httpResp.Body.Close() if err != nil { return } if httpResp.StatusCode == 200 { println(fmt.Sprintf("resp body:%s", string(respBody))) } else { println(fmt.Sprintf("http resp code: %d, resp body:%s", httpResp.StatusCode, string(respBody))) } } ``` -------------------------------- ### List of Nodes (Example) Source: https://help.niulinkcloud.cn/openapi/smallbox/query/ant_info_list This section illustrates the expected response format for a successful request to retrieve a list of nodes. It includes details about node status, network information, and scheduling. ```APIDOC ## GET /websites/help_niulinkcloud_cn_openapi/nodes ### Description Retrieves a list of nodes with their associated information, including network configuration, status, and scheduling details. ### Method GET ### Endpoint /websites/help_niulinkcloud_cn_openapi/nodes ### Parameters #### Query Parameters * None specified #### Request Body * None ### Request Example * N/A ### Response #### Success Response (200) - **items** (array) - A list of node objects. - **nodeID** (string) - The unique identifier for the node. - **vendorID** (integer) - The identifier for the vendor. - **stage** (string) - The current stage of the node (e.g., "submitted"). - **nodeInfo** (object) - Information about the node's hardware and network. - **arch** (string) - The CPU architecture of the node. - **sn** (string) - The serial number of the node. - **status** (string) - The current operational status of the node (e.g., "online"). - **host** (string) - The hostname of the node. - **clientIP** (object) - Network details of the client. - **ip** (string) - The public IP address. - **ipv6** (string) - The IPv6 address (if available). - **intranetIP** (string) - The private IP address. - **province** (string) - The province where the node is located. - **city** (string) - The city where the node is located. - **isp** (string) - The Internet Service Provider. - **combinedData** (object) - Combined network data. - **upnpErrDetail** (string) - Details of UPnP errors. - **upnpAddResult** (string) - Result of UPnP addition. - **tcpNatType** (string) - The TCP NAT type. - **nominalInfo** (object) - Nominal network information. - **province** (string) - The province. - **city** (string) - The city. - **isp** (string) - The ISP. - **natType** (string) - The NAT type. - **dialType** (string) - The dial type. - **isMultiLine** (boolean) - Whether multi-line is enabled. - **bwNum** (integer) - The number of bandwidth channels. - **isTransProv** (boolean) - Whether cross-province is enabled. - **transProvRate** (integer) - The cross-province rate. - **remark** (string) - Any remarks. - **netSchedule** (object) - Network scheduling configuration. - **type** (string) - The type of scheduling (e.g., "timeRangeExperience"). - **timeRangeExperience** (object) - Time range experience details. - **timeRanges** (array) - List of time ranges. - **startElapsedSecs** (integer) - Start time in seconds from epoch. - **endElapsedSecs** (integer) - End time in seconds from epoch. - **count** (integer) - The total number of nodes returned. #### Response Example ```json { "items": [ { "nodeID": "ant153175188d886a81f42f671641b93", "vendorID": 1, "stage": "submitted", "nodeInfo": { "arch": "amd64", "sn": "2P7R4X1", "status": "online", "host": "Sparrow64.site", "clientIP": { "ip": "180.159.35.120", "ipv6": "", "intranetIP": "192.168.122.161", "province": "上海", "city": "上海", "isp": "电信" }, "combinedData": { "upnpErrDetail": "no upnp server", "upnpAddResult": "failure", "tcpNatType": "NAT1" } }, "nominalInfo": { "province": "上海", "city": "上海", "isp": "电信", "natType": "symmetric", "dialType": "dhcpNetSingle", "isMultiLine": false, "bwNum": 1, "isTransProv": true, "transProvRate": 100, "remark": "remark" }, "netSchedule": { "type": "timeRangeExperience", "timeRangeExperience": { "timeRanges": [ { "startElapsedSecs": 0, "endElapsedSecs": 64800 }, { "startElapsedSecs": 64800, "endElapsedSecs": 86400 } ] } } } ], "count": 1 } ``` ``` -------------------------------- ### Request Example - Get Node Converge Status Source: https://help.niulinkcloud.cn/openapi/smallbox/query/ant_dail_converge_status Example of how to make a GET request to the /v1/ant//dialconverge/status endpoint. This request requires an Authorization header and the nodeID in the path. ```shell GET /v1/ant//dialconverge/status Host: api.niulinkcloud.cn Authorization: Bearer ``` -------------------------------- ### Response Example for Fetching Business List (Success) Source: https://help.niulinkcloud.cn/openapi/common/node_customer_list Example of a successful JSON response (HTTP 200) from the /v1/customers endpoint, showing the structure of the returned business data. ```JSON { "items": [ { "externalName": "业务T", "openId": 1, "createAt": 1590000000000, "externalDescription": "业务描述", "serveRequirement": "上机文档要求", "callInDescription": "招募文档简介" } ], "count":1 } ``` -------------------------------- ### Get All Node Status API Response Example (Success) Source: https://help.niulinkcloud.cn/openapi/smallbox/query/node_list_status Example of a successful HTTP 200 response from the /v1/ant/status API. The response contains a list of nodes, each with details such as nodeID, stage, status, netBenchStatus, and remark. ```json { "items": [ { "nodeID": "5f1e9dc7f9537d6b370xx010", "stage": "audit", "status": "online", "netBenchStatus": "done", "remark": "remark" } ] } ``` -------------------------------- ### SLA Details Response Example (Success) Source: https://help.niulinkcloud.cn/openapi/smallbox/bill/sla_info This is an example of a successful response (HTTP 200) from the /v1/ant/bill/sla endpoint, showing SLA details for different nodes and billing information for the specified date range. ```json { "slaDetails":{ "002a3e275fb274a9795034643548d322":[ { "day":"2022-07-27" }, { "day":"2022-07-28" } ], "002d8da247673d3f17996ac87433bd81":[ { "day":"2022-07-27" } ] }, "billingInfos":[ { "day":"2022-07-27", "isBilling":false }, { "day":"2022-07-28", "isBilling":true } ] } ``` -------------------------------- ### Get Node Converge Status API Response Example (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_dail_converge_status This example shows a successful JSON response from the 'Get Node Converge Status' endpoint. It details the node's dial status, aggregated line counts, and network interface information. ```json { "convergeStatus": "idle", "total": 10, "connectSucceed": 5, "detail": [ { "netDevName": "eth0", "ip": "172.0.0.1", "mac": "ff:dd:cc:bb:aa", "speed": "1Gbit/s", "type": "traffic", "total": 10, "connectSucceed": 5, "convergeStatusInfo": [ { "netDevName": "eth0", "vlanId": 110, "mac": "ff:dd:cc:bb:aa", "ip": "172.0.0.2", "gateway": "172.0.0.1", "ipv6": "fe80::d6ae:52ff:fe6c:b36e", "ipv6Gateway": "fe80::d6ae:52ff:fe6c:b36e", "mask": "255.255.255.0", "connectStatus": "success", "ipv6ConnectStatus": "success", "convergeError": "xxxx" } ] } ] } ``` -------------------------------- ### Get Node Dial Status Request (HTTP) Source: https://help.niulinkcloud.cn/openapi/smallbox/query/ant_dail_status Example of an HTTP GET request to retrieve the dial status of a node. This request requires an Authorization header and the nodeID as a path parameter. ```http GET /v1/ant/12345/dial/status HTTP/1.1 Host: api.niulinkcloud.cn Authorization: Bearer YOUR_TOKEN ``` -------------------------------- ### Request Example for Node Metered Bandwidth (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_day_measure This snippet demonstrates the JSON payload structure for requesting node metered bandwidth information. It includes the required node IDs, start date, and end date. The request uses the POST method to the /v1/nodes/daymeasure/stats endpoint and expects a JSON response. ```json { "nodeIDs": ["hdshkdjsdkj", "hdshkdjdasd"], "start": "2024-10-01", "end": "2024-10-10" } ``` -------------------------------- ### Node Quality Report Response Example (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_quality_report This example demonstrates the structure of a successful response (HTTP 200) when requesting a node's quality report. It includes nested objects for basic device information, hardware specifications, disk I/O performance, and network pressure test results. An example of an error response (HTTP 4xx/5xx) is also provided. ```json { "basic": { "province": "上海", "city": "上海", "isp": "电信", "usbw": 10, "bwNum": 100, "bandwidth": 1000, "natType": "public", "dialType": "staticNetSingle", "resourceType": "dedicated" }, "hardware": { "CPUFreq": "2.4G", "CPUThreads": 4, "mem": 10000, "diskInfo": "", "averageIOPS": 100 }, "diskIOPS": [ { "name": "dev1", "type": "HDD", "size": "100", "iops": 10, "measureCost": "" } ], "pressure": [ { "pressureTime": 1234567890123, "lines": [ { "lineName": "ppp1", "ip": "127.0.0.1", "expectedBw": 1000, "actualBw": 900, "rtt": 20, "tcpRetryMissRate": 10, "limitBw": 800, "businessOfLine": true, "records": [ { "out": 10, "rtRate": 3, "rtt": 10 }, { "out": 20, "rtRate": 5, "rtt": 20 } ] } ] } ] } // Error Response Example { "code": 4000001, "desc": "" } ``` -------------------------------- ### POST /v1/nodes/stats Source: https://help.niulinkcloud.cn/openapi/demo/java Retrieves statistics for specified nodes within a given date range. ```APIDOC ## POST /v1/nodes/stats ### Description Retrieves statistics for specified nodes within a given date range. This endpoint is useful for monitoring node performance and activity. ### Method POST ### Endpoint `https://api.niulinkcloud.com/v1/nodes/stats` ### Parameters #### Request Body - **nodeIDs** (array of strings) - Required - A list of node IDs for which to retrieve statistics. - **start** (string) - Required - The start date for the statistics in YYYY-MM-DD format. - **end** (string) - Required - The end date for the statistics in YYYY-MM-DD format. ### Request Example ```json { "nodeIDs": ["your_node_id_1", "your_node_id_2"], "start": "2024-03-26", "end": "2024-03-27" } ``` ### Response #### Success Response (200) - **code** (integer) - The status code of the response. - **data** (object) - Contains the statistics for the requested nodes. - **nodeID** (string) - The ID of the node. - **stats** (array) - An array of statistical data points for the node. - **time** (string) - The timestamp of the data point. - **upload_bytes** (integer) - Uploaded bytes. - **download_bytes** (integer) - Downloaded bytes. - **upload_packets** (integer) - Uploaded packets. - **download_packets** (integer) - Downloaded packets. - **error_packets** (integer) - Error packets. - **drop_packets** (integer) - Dropped packets. - **avg_latency** (integer) - Average latency in milliseconds. #### Response Example ```json { "code": 200, "data": [ { "nodeID": "your_node_id_1", "stats": [ { "time": "2024-03-26T00:00:00Z", "upload_bytes": 102400, "download_bytes": 204800, "upload_packets": 100, "download_packets": 200, "error_packets": 0, "drop_packets": 0, "avg_latency": 50 } ] } ], "message": "成功" } ``` ``` -------------------------------- ### Node Disk Information Response Example (Error) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_disk_info Example of an error response (HTTP 4xx/5xx) from the API. It returns an error code and a description of the issue encountered during the request. ```json { "code": 4000001, "desc": "Error description" } ``` -------------------------------- ### Node Dial Status Response Example (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_dail_status This JSON example illustrates a successful response from the node dial status API. It shows the main 'dialStatus' as 'idle', indicating readiness for a new dial, and provides a detailed 'detail' array. Each item in 'detail' represents a network interface, including its name, IP, speed, type, and a list of 'dialStatusInfo' for individual connection attempts, detailing account, IP, VLAN, dial status, and connection status. ```json { "dialStatus": "idle", "detail": [ { "netDevName": "eth0", "ip": "172.0.0.1", "speed": "1Gbit/s", "type": "traffic", "dialStatusInfo": [ { "account": "05120001110", "ip": "120.110.111.112", "ipv6": "fe80::d6ae:52ff:fe6c:b36e", "ipv6ConnectStatus": "succeed", "password": "12345", "adslNum": 10, "vlanId": 201, "dialStatus": "failed", "connectStatus": "failed", "dialError": "xxxx" } ] } ] } ``` -------------------------------- ### Get Node Status (HTTP Request Example) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_status This snippet demonstrates how to make an HTTP GET request to retrieve the status of a specific node using its ID. It includes the endpoint path and required headers such as Authorization. The response will contain various status indicators for the node. ```http GET /v1/nodes//status HTTP/1.1 Host: niulink.cloud Authorization: Bearer ``` -------------------------------- ### Get Node Converge Status API Request Example (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_dail_converge_status This snippet demonstrates a typical JSON request to the 'Get Node Converge Status' endpoint. It includes the necessary path parameters and headers for authentication and identifying the target node. ```bash GET /v1/nodes//dialconverge/status Headers: Authorization: Bearer Path Parameters: nodeID: ``` -------------------------------- ### Node List Query Example Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_info_list An example HTTP request to the node list query endpoint. This demonstrates how to use query parameters like `query`, `queryType`, `status`, and `stage` to filter and search for nodes. ```HTTP http://niulinkcloud-example/v1/nodes/info/list?query=hjsfkjhsfh5637587&queryType=nodeId&status=online&stage=bound ``` -------------------------------- ### Batch Get Node Bandwidth Info Response Example (JSON) Source: https://help.niulinkcloud.cn/openapi/niulink/query/node_batch_stats This JSON object illustrates a successful response from the batch node bandwidth information endpoint. It contains an array 'nodeDatas', where each element represents a node and includes its ID, bandwidth data ('data' array with time, up, and down metrics), and an 'errorCode'. ```json { "nodeDatas": [ { "nodeId": "xx", "data": [ { "time": 1740362400, "up": 1000, "down": 2000 }, { "time": 1740366000, "up": 1000, "down": 2000 } ], "errorCode": 0 } ] } ```