接入教程
1. 注册SwiftKanban账户并登录
2. 在设置中生成API密钥
3. 查看官方文档了解端点
4. 使用REST客户端测试API调用
5. 集成到您的应用程序中
使用Python获取所有看板
python
import requests
url = "https://api.example.com/boards"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
boards = response.json()
print(f"Found {len(boards)} boards")
else:
print(f"Error: {response.status_code}", response.text)
使用PHP创建新看板卡片
php
<?php
$url = "https://api.example.com/cards";
$apiKey = "YOUR_API_KEY";
$data = [
"title" => "New Task",
"description" => "Task description here",
"laneId" => 123
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 201) {
echo "Card created successfully.";
} else {
echo "Error: " . $httpCode . " - " . $response;
}
?>
使用JavaScript更新卡片状态
javascript
const url = "https://api.example.com/cards/456";
const apiKey = "YOUR_API_KEY";
const updateData = {
"laneId": 789,
"priority": "High"
};
fetch(url, {
method: "PUT",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify(updateData)
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => console.log("Card updated:", data))
.catch(error => console.error("Error:", error));
常见问题
如何获取API密钥?
API密钥通常在SwiftKanban账户的管理设置或开发者部分生成。请登录您的SwiftKanban实例,查看相关文档或联系管理员获取。
API请求的速率限制是多少?
速率限制因您的订阅计划而异。请参考官方文档或查看API响应头中的X-RateLimit-Limit和X-RateLimit-Remaining字段。
支持哪些认证方式?
SwiftKanban API主要支持Bearer令牌认证,使用在授权头中传递的API密钥。部分端点可能也支持基本认证,但建议使用令牌方式。
Aitishiku.com