GitHub Trend Monitor API文档

本文档详细记录了GitHub Trend Monitor项目中使用的所有API,包括GitHub API和DashScope API。

目录

  1. GitHub API
  2. DashScope API

GitHub API

GitHub API是一个RESTful API,基础URL为 https://api.github.com

仓库基本信息

获取仓库的基本信息,包括星标数、分支数、问题数等。

请求:

GET /repos/{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

参数:

示例响应:

[
  {
    "login": "contributor-username",
    "id": 12345678,
    "avatar_url": "https://avatars.githubusercontent.com/u/12345678",
    "contributions": 100
  }
]

返回顶部

问题(Issues)

获取仓库的问题列表。

请求:

GET /repos/{owner}/{repo}/issues

参数:

示例响应:

[
  {
    "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 Requests

获取仓库的Pull Request列表。

请求:

GET /repos/{owner}/{repo}/pulls

参数:

示例响应:

[
  {
    "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
  }
]

返回顶部

提交(Commits)

获取仓库的提交历史。

请求:

GET /repos/{owner}/{repo}/commits

参数:

示例响应:

[
  {
    "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 认证方式

GitHub API使用个人访问令牌(Personal Access Token)进行认证。

认证方式:

Authorization: token YOUR_GITHUB_TOKEN

使用说明:

  1. 在GitHub个人设置中创建访问令牌
  2. 在API请求头中添加Authorization字段
  3. 未认证状态下,API有严格的速率限制(60次/小时)
  4. 认证后可提高速率限制(5000次/小时)

返回顶部

DashScope API

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
}

参数说明:

流式响应格式:

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 认证方式

DashScope API使用Bearer令牌进行认证。

认证方式:

Authorization: Bearer YOUR_DASHSCOPE_TOKEN

使用说明:

  1. 在阿里云DashScope控制台创建API令牌
  2. 在API请求头中添加Authorization字段
  3. 令牌格式通常为sk-开头的字符串

返回顶部