| 接口类型 | 认证要求 | 请求头 |
|---|---|---|
| 公开接口 | 无需认证 | 不需要 |
| 安全接口 | 需要 API Key | X-API-Key: your-api-key-here |
{
"function_name": "light_on",
"source_app": "YourAppName"
}| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| function_name | string | 是 | 函数名称,从下方列表中选择 |
| source_app | string | 是 | 您的应用标识符(最大50字符) |
| param_string | string | 否 | 直接命令参数(高级用户使用) |
{
"success": true,
"param_string": "P1:1,0,3",
"function_name": "light_on",
"message": "Command received and logged"
}{
"success": false,
"error": "Function 'light_on' not found"
}curl -X POST https://hcs.bjblk.store/api/external/execute \
-H "Content-Type: application/json" \
-d '{"function_name": "light_on", "source_app": "MyApp"}'fetch('https://hcs.bjblk.store/api/external/execute', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
function_name: 'light_on',
source_app: 'MyApp'
})
})
.then(res => res.json())
.then(console.log)
.catch(console.error);// Android with OkHttp
OkHttpClient client = new OkHttpClient();
JSONObject json = new JSONObject();
json.put("function_name", "light_on");
json.put("source_app", "MyApp");
RequestBody body = RequestBody.create(
json.toString(),
MediaType.parse("application/json")
);
Request request = new Request.Builder()
.url("https://hcs.bjblk.store/api/external/execute")
.post(body)
.build();
client.newCall(request).enqueue(new Callback() {
public void onResponse(Call call, Response response) {
Log.d("HCS", response.body().string());
}
public void onFailure(Call call, IOException e) {
Log.e("HCS", e.getMessage());
}
});// iOS Swift
let url = URL(string: "https://hcs.bjblk.store/api/external/execute")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: Any] = [
"function_name": "light_on",
"source_app": "MyApp"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
let task = URLSession.shared.dataTask(with: request) { data, _, error in
guard let data = data else { return }
print(String(data: data, encoding: .utf8) ?? "")
}
task.resume()// HarmonyOS ArkTS
import http from '@ohos.net.http';
let httpRequest = http.createHttp();
let body = {
function_name: 'light_on',
source_app: 'MyApp'
};
httpRequest.request('https://hcs.bjblk.store/api/external/execute', {
method: http.RequestMethod.POST,
header: { 'Content-Type': 'application/json' },
extraData: JSON.stringify(body)
}, (err, data) => {
if (!err && data.responseCode === 200) {
console.info(JSON.parse(data.result));
}
});# Python
import requests
response = requests.post(
'https://hcs.bjblk.store/api/external/execute',
json={'function_name': 'light_on', 'source_app': 'MyApp'}
)
print(response.json())| HTTP状态 | 错误码 | 说明 |
|---|---|---|
| 200 | success | 请求成功 |
| 400 | invalid_request | JSON格式错误或缺少参数 |
| 401 | unauthorized | API Key 无效或缺失 |
| 404 | not_found | 函数名称不存在 |
| 429 | rate_limited | 请求频率超限(100次/分钟) |
| 500 | server_error | 服务器内部错误 |
| 接口 | 限制 |
|---|---|
| /external/execute | 100 次/分钟 |
| /command-mappings | 1000 次/分钟 |
| /external/execute-secure | 50 次/分钟 |
| Endpoint Type | Authentication | Header |
|---|---|---|
| Public Functions | No Authentication | None required |
| Secure Functions | API Key Required | X-API-Key: your-api-key-here |
{
"function_name": "light_on",
"source_app": "YourAppName"
}| Parameter | Type | Required | Description |
|---|---|---|---|
| function_name | string | Yes | Function name from available list |
| source_app | string | Yes | Your application identifier (max 50 chars) |
| param_string | string | No | Direct command (advanced users only) |
{
"success": true,
"param_string": "P1:1,0,3",
"function_name": "light_on",
"message": "Command received and logged"
}{
"success": false,
"error": "Function 'light_on' not found"
}curl -X POST https://hcs.bjblk.store/api/external/execute \
-H "Content-Type: application/json" \
-d '{"function_name": "light_on", "source_app": "MyApp"}'fetch('https://hcs.bjblk.store/api/external/execute', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
function_name: 'light_on',
source_app: 'MyApp'
})
})
.then(res => res.json())
.then(console.log)
.catch(console.error);// Android with OkHttp
OkHttpClient client = new OkHttpClient();
JSONObject json = new JSONObject();
json.put("function_name", "light_on");
json.put("source_app", "MyApp");
RequestBody body = RequestBody.create(
json.toString(),
MediaType.parse("application/json")
);
Request request = new Request.Builder()
.url("https://hcs.bjblk.store/api/external/execute")
.post(body)
.build();
client.newCall(request).enqueue(new Callback() {
public void onResponse(Call call, Response response) {
Log.d("HCS", response.body().string());
}
public void onFailure(Call call, IOException e) {
Log.e("HCS", e.getMessage());
}
});// iOS Swift
let url = URL(string: "https://hcs.bjblk.store/api/external/execute")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body: [String: Any] = [
"function_name": "light_on",
"source_app": "MyApp"
]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
let task = URLSession.shared.dataTask(with: request) { data, _, error in
guard let data = data else { return }
print(String(data: data, encoding: .utf8) ?? "")
}
task.resume()// HarmonyOS ArkTS
import http from '@ohos.net.http';
let httpRequest = http.createHttp();
let body = {
function_name: 'light_on',
source_app: 'MyApp'
};
httpRequest.request('https://hcs.bjblk.store/api/external/execute', {
method: http.RequestMethod.POST,
header: { 'Content-Type': 'application/json' },
extraData: JSON.stringify(body)
}, (err, data) => {
if (!err && data.responseCode === 200) {
console.info(JSON.parse(data.result));
}
});# Python
import requests
response = requests.post(
'https://hcs.bjblk.store/api/external/execute',
json={'function_name': 'light_on', 'source_app': 'MyApp'}
)
print(response.json())| HTTP Status | Code | Description |
|---|---|---|
| 200 | success | Request successful |
| 400 | invalid_request | Malformed JSON or missing parameters |
| 401 | unauthorized | Invalid or missing API key |
| 404 | not_found | Function name not found |
| 429 | rate_limited | Rate limit exceeded (100 requests/minute) |
| 500 | server_error | Internal server error |
| Endpoint | Limit |
|---|---|
| /external/execute | 100 requests per minute |
| /command-mappings | 1000 requests per minute |
| /external/execute-secure | 50 requests per minute |