Skip to Content

身份认证

所有 API 请求都需要使用 Bearer Token(API 密钥)进行身份认证。

创建 API 密钥

  1. 登录 IronFlock app.ironflock.com
  2. 进入 User Settings
  3. 导航到 API Keys 部分。
  4. 点击 Create API Key
  5. 复制生成的密钥——密钥仅显示一次。

使用 API 密钥

在每个请求的 Authorization 头中包含密钥:

curl -H "Authorization: Bearer YOUR_API_KEY" \ https://api.ironflock.com/v1/ironflock/devices

Python 示例

import requests API_KEY = "your-api-key" BASE_URL = "https://api.ironflock.com/v1/ironflock" headers = {"Authorization": f"Bearer {API_KEY}"} response = requests.get(f"{BASE_URL}/devices", headers=headers) devices = response.json()

JavaScript 示例

const API_KEY = "your-api-key"; const BASE_URL = "https://api.ironflock.com/v1/ironflock"; const response = await fetch(`${BASE_URL}/devices`, { headers: { Authorization: `Bearer ${API_KEY}` } }); const devices = await response.json();

错误响应

状态码含义
401API 密钥缺失或无效
403权限不足,无法执行此操作
404资源未找到
422验证错误(请检查请求参数)
500服务器内部错误

所有错误响应返回 JSON 对象:

{ "error": "Description of the error" }
Last updated on