通过该API接口可以查询所有带imei的设备的型号、品牌、厂商等基本信息。
一、使用API
1、请求信息
(1)请求地址:
https://open-api.51gcc.com
(2)请求方法:
POST
(3)请求参数
| 参数名 | 是否必填 | 说明 | 参数值 |
|---|---|---|---|
| sn | 是 | IMEI | 设备的IMEI |
| api_id | 是 | api_id | 1 |
| api_test | 是 | 是否模拟请求返回示例数据。1=是;0=否 | 1 |
| api_key | 是 | 用户中心的API密钥 | 自己的API密钥 查看秘钥 |
2、响应结果
(1)结果字段说明:
字段名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
image | string | 设备图片 | https://snapi.51gcc.com/storage/site/no_name.png |
key | string | 字段名 | model |
text | string | 字段含义 | 型号 |
value | string|array | 字段含义对应的查询结果 | iPhone XR |
| notice | string | 对value字段含义的补充说明 | 用于查询保修的凭证号码 |
(2)成功示例:
{ "code": 200, "msg": "ok", "data": { "image": "https://snapi.51gcc.com/storage/site/no_name.png", "result": [ { "key": "imei", "text": "imei", "value": 356698882008924, "notice": "" }, { "key": "model", "text": "型号", "value": "iPhone 16 Pro", "notice": "" }, { "key": "product", "text": "入网型号", "value": "A3294", "notice": "" }, { "key": "manufacturer", "text": "品牌", "value": "Apple", "notice": "" }, { "key": "device_type", "text": "设备类型", "value": "SMARTPHONE", "notice": "" }, { "key": "is_phone", "text": "是否手机", "value": "是", "notice": "" } ], "other_result": [] } }(3)失败示例:
{ "code": 403, "msg": "签名错误", "time": 1770703778, "data": [] }(4)状态码说明
状态码 | 说明 |
|---|---|
200 | 请求成功,服务器已成功处理了请求。 |
210 | 参数错误。 |
220 | 系统功能异常。 |
230 | 数据获取失败。 |
403 | 服务器拒绝请求。这可能是由于缺少必要的认证凭据(如API密钥)或权限不足。 |
404 | 请求的资源未找到。请检查您的请求地址是否正确。 |
429 | 请求过于频繁。您已超出速率限制,请稍后再试。 |
500 | 服务器内部错误。服务器在执行请求时遇到了问题。 |
600 | API账户余额不足。 |
二、调用示例
PHP示例
<?php $url = 'https://open-api.51gcc.com'; $params = ['sn' => 'YOUR_VALUE', 'api_id' => '1', 'api_test' => 'YOUR_VALUE', 'api_key' => 'YOUR_VALUE', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?>Python示例
import requests url = "https://open-api.51gcc.com" params = { 'sn': 'YOUR_VALUE', 'api_id': '1', 'api_test': 'YOUR_VALUE', 'api_key': 'YOUR_VALUE', } response = requests.post(url, data=params) print(response.text)Java示例
import java.io.*; import java.net.*; import java.util.*; public class ApiClient { public static void main(String[] args) throws Exception { String url = "https://open-api.51gcc.com"; Map<String, String> params = new HashMap<>(); params.put("sn", "YOUR_VALUE"); params.put("api_id", "1"); params.put("api_test", "YOUR_VALUE"); params.put("api_key", "YOUR_VALUE"); URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setDoOutput(true); StringBuilder postData = new StringBuilder(); for (Map.Entry<String, String> param : params.entrySet()) { if (postData.length() != 0) postData.append('&'); postData.append(URLEncoder.encode(param.getKey(), "UTF-8")); postData.append('='); postData.append(URLEncoder.encode(param.getValue(), "UTF-8")); } try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.writeBytes(postData.toString()); } int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); System.out.println(response.toString()); } }