本文档详细记录了GitHub Trend Monitor项目中使用的所有API,包括GitHub API和DashScope API。
GitHub API是一个RESTful API,基础URL为 https://api.github.com
。
获取仓库的基本信息,包括星标数、分支数、问题数等。
请求:
GET /repos/{owner}/{repo}
参数:
owner
- 仓库所有者用户名repo
- 仓库名称示例响应:
{
"id": 12345678,
"name": "repository-name",
"full_name": "owner/repository-name",
"description": "Repository description",
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/12345678"
},
"stargazers_count": 1000,
"forks_count": 500,
"open_issues_count": 50,
"created_at": "2020-01-01T00:00:00Z",
"updated_at": "2022-01-01T00:00:00Z"
}
获取仓库的贡献者列表。
请求:
GET /repos/{owner}/{repo}/contributors
参数:
owner
- 仓库所有者用户名repo
- 仓库名称per_page
- 每页显示的条目数 (可选,默认30,最大100)示例响应:
[
{
"login": "contributor-username",
"id": 12345678,
"avatar_url": "https://avatars.githubusercontent.com/u/12345678",
"contributions": 100
}
]
获取仓库的问题列表。
请求:
GET /repos/{owner}/{repo}/issues
参数:
owner
- 仓库所有者用户名repo
- 仓库名称state
- 问题状态 (open
, closed
, all
,默认为open
)page
- 页码 (可选,默认为1)per_page
- 每页显示的条目数 (可选,默认30,最大100)sort
- 排序字段 (created
, updated
, comments
,默认为created
)direction
- 排序方向 (asc
, desc
,默认为desc
)示例响应:
[
{
"number": 1,
"title": "Issue title",
"state": "open",
"user": {
"login": "username"
},
"created_at": "2020-01-01T00:00:00Z",
"updated_at": "2020-01-02T00:00:00Z",
"closed_at": null,
"body": "Issue description",
"comments": 5,
"labels": [
{
"name": "bug",
"color": "fc2929"
}
]
}
]
获取仓库的Pull Request列表。
请求:
GET /repos/{owner}/{repo}/pulls
参数:
owner
- 仓库所有者用户名repo
- 仓库名称state
- PR状态 (open
, closed
, all
,默认为open
)per_page
- 每页显示的条目数 (可选,默认30,最大100)示例响应:
[
{
"number": 1,
"title": "Pull request title",
"state": "open",
"user": {
"login": "username"
},
"created_at": "2020-01-01T00:00:00Z",
"updated_at": "2020-01-02T00:00:00Z",
"closed_at": null,
"merged_at": null
}
]
获取仓库的提交历史。
请求:
GET /repos/{owner}/{repo}/commits
参数:
owner
- 仓库所有者用户名repo
- 仓库名称per_page
- 每页显示的条目数 (可选,默认30,最大100)示例响应:
[
{
"sha": "commit-hash",
"commit": {
"author": {
"name": "Author Name",
"email": "author@example.com",
"date": "2020-01-01T00:00:00Z"
},
"message": "Commit message"
},
"author": {
"login": "username",
"avatar_url": "https://avatars.githubusercontent.com/u/12345678"
}
}
]
GitHub API使用个人访问令牌(Personal Access Token)进行认证。
认证方式:
Authorization: token YOUR_GITHUB_TOKEN
使用说明:
Authorization
字段DashScope是阿里云提供的AI大模型服务,提供多种AI能力,包括自然语言处理、图像识别等。
使用兼容OpenAI接口格式的聊天补全API。
请求:
POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions
请求头:
Content-Type: application/json
Authorization: Bearer YOUR_DASHSCOPE_TOKEN
请求体:
{
"model": "qwen-max",
"messages": [
{
"role": "system",
"content": "你是一个有用的GitHub仓库分析助手。你能提供简洁、有深度的仓库数据分析。"
},
{
"role": "user",
"content": "请分析以下GitHub仓库数据..."
}
],
"stream": true
}
参数说明:
model
- 使用的模型,如"qwen-max"messages
- 消息数组,包含对话历史stream
- 是否使用流式响应,设为true时逐步返回生成结果流式响应格式:
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"qwen-max","choices":[{"index":0,"delta":{"content":"分析"},"finish_reason":null}]}
data: {"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"qwen-max","choices":[{"index":0,"delta":{"content":"结果"},"finish_reason":null}]}
data: [DONE]
DashScope API使用Bearer令牌进行认证。
认证方式:
Authorization: Bearer YOUR_DASHSCOPE_TOKEN
使用说明:
Authorization
字段sk-
开头的字符串