Skip to content

BillionMail API使用指南

1. 获取API密钥

进入设置 页面查看并复制API密钥

2. 启用Swagger API文档

Swagger是一个流行的API文档工具,启用方法如下:

设置页面中启用Swagger

3. 访问Swagger文档

服务启动后,您可以通过以下URL访问Swagger UI界面:

text
https://your-domain.com/swagger

在Swagger界面中,您可以:

  • 查看所有可用的API端点

  • 查看每个API的请求参数、响应格式

  • 直接测试API调用

4. 设置请求头认证

调用API时,需要在请求头中添加认证信息:

text
Authorization: Bearer your_api_key_here

示例curl命令:

bash
curl -X GET "https://your-domain.com/api/endpoint" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json"

5. API调试与对接

调试API

使用Swagger界面直接测试API调用

使用Postman等工具构建请求:

  • 设置正确的HTTP方法(GET/POST/PUT/DELETE等)

  • 添加Authorization头

  • 添加必要的请求参数或body

检查响应状态码和返回数据

对接API

根据您的开发环境,可以选择以下方式对接API:

前端对接

javascript
fetch('https://your-domain.com/api/endpoint', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer your_api_key_here',
    'Content-Type': 'application/json'
  }
})
.then(response => response.json())
.then(data => console.log(data));

后端对接

python
import requests

url = "https://your-domain.com/api/endpoint"
headers = {
    "Authorization": "Bearer your_api_key_here",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json())

命令行对接

bash
# 使用curl
curl -X GET "https://your-domain.com/api/endpoint" \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json"

Released under the AGPLv3 License