概述
欢迎使用
接口调用流程
URI结构
https://rest_api_root/v1[/{area}]/{resource}
https://open.pingcode.com/v1/scm/products
https://open.pingcode.com/v1/scm/products/{product_id}/repositories
https://open.pingcode.com/v1/release/environments
rest_api_root
表示根路径,在不同的环境中根路径有所不同:公有云的REST API根路径:https://open.pingcode.com
私有部署的REST API根路径:https://xxxxxx/open
数据结构
全量结构
{
"id": "5e05d8448f8461dada9ba29c",
"url": "https://rest_api_root/v1/{resource}",
"name": "资源名称",
"desc": "资源简介",
"created_at": 1578897962
}
引用结构
{
"id": "5e05d8448f8461dada9ba29c",
"url": "https://rest_api_root/v1/{resource}",
"name": "资源名称"
}
使用方式
OPTIONS/GET/PUT/PATCH/POST/DELETE
等标准的HTTP请求。 对于GET/DELETE
请求,通过querystring传递参数;对于POST/PUT/PATCH
请求,需要在headers
中添加"content-type": "application/json"
,然后通过body传递参数。 PingCode REST API使用HTTP状态码指示已执行操作的状态; 使用response body
传递数据。单个资源
HTTP状态码:201
Body:
{
"id": "5e05d8448f8461dada9ba29c",
"url": "https://rest_api_root/v1/{resource}",
"name": "资源名称",
"desc": "资源简介",
"created_at": 1578897962
}
分页数据
querystring
中设置page_siz
e和page_index
,指定每一页的数据量和第几页的数据(page_index
为0时,表示第一页)。 在返回的数据结构中,page_size
表示当前每页的数据量,page_index
表示当前在第几页,total
表示资源总数量,values
表示资源的数组。HTTP状态码:200
Body:
{
"page_size": 30,
"page_index": 0,
"total": 100,
"values": [
{
"id": "5e05d8448f8461dada9ba29c",
"url": "https://rest_api_root/v1/{resource}",
"name": "资源名称",
"desc": "资源简介",
"created_at": 1578897962
},
...
]
}
错误
HTTP状态码:500
Body:
{
"code": "100000",
"message": "Internal Server Error"
}
频率限制
具体策略
HTTP状态码:429
Headers:
{
"x-pc-retry-after": 50
}
Body:
{
"code": "100038",
"message": "请求频率过高"
}
x-pc-retry-after
指示使用者在重新请求之前必须等待的秒数。如果使用者在到期之前重新发出请求,则请求会再次失败并返回相同的HTTP状态码和response body
。合理请求
Webhook
和发送HTTP
请求来将PingCode中发生变更的数据发送给订阅者,也可以有效降低 PingCode REST API的请求数量,从而降低遇到频率限制的风险。修改于 2024-08-22 07:12:04