API概述

API概述:


Drone提供了一个全面的API,用于与Drone服务器交互。文档的此部分提供了用于验证和使用远程API的说明。

官方库

Drone提供以下官方库用于与API集成:

语言 项目地址
Go https://github.com/drone/drone-go
Node https://github.com/drone/drone-node

验证

  • Drone使用tokens进行身份验证。您可以从Drone用户界面中Account菜单SHOW TOKEN显示您的用户tokens。您可以在httpHeaders中添加Authorization属性提供tokens
  • 后期需要用户验证的API我们以这种形式进行说明。
Authorization:{tokens}
  • 例子
curl -X GET -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoiYWRtaW51c2VyIiwidHlwZSI6InVzZXIifQ.p2KhqJ-hl7lVdWawKtowBucWRANmYLv6ZqY64-gE660" "http://192.168.56.21/api/user"
  • 响应
Status: 200 OK
Content-Type: application/json
{
  "id": 1,
  "login": "adminuser",
  "email": "[email protected]",
  "avatar_url": "https://secure.gravatar.com/avatar/0f656b0b09d16bafa95064e7e9bd83bc",
  "active": false,
  "admin": true
}
  • 或者使用access_token做为查询参数:
http://drone.com/api/user?access_token={tokens}
  • 例子
curl -X GET "http://192.168.56.21/api/user?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0ZXh0IjoiYWRtaW51c2VyIiwidHlwZSI6InVzZXIifQ.p2KhqJ-hl7lVdWawKtowBucWRANmYLv6ZqY64-gE660"
  • 响应
Status: 200 OK
Content-Type: application/json
{
  "id": 1,
  "login": "adminuser",
  "email": "[email protected]",
  "avatar_url": "https://secure.gravatar.com/avatar/0f656b0b09d16bafa95064e7e9bd83bc",
  "active": false,
  "admin": true
}

你可能感兴趣的:(API概述)