GitHub Search Code

1积分/次
ae_github_search_code

在 GitHub 仓库的文件中搜索特定代码(如函数、类或关键词),支持按编程语言、仓库、文件名或内容筛选。

效率工具
1积分/次

价格说明

1积分/次
条件费用
每次调用1积分/次

工具参数

未传入的可选参数将使用平台默认值。

参数类型必填说明默认值
qstring是The query contains one or more search keywords and qualifiers. Qualifiers allow you to limit your search to specific areas of GitHub. The REST API supports the same qualifiers as the web interface for GitHub. To learn more about the format of the query, see [Constructing a search query](https://docs.github.com/rest/search/search#constructing-a-search-query). See "[Searching code](https://docs.github.com/search-github/searching-on-github/searching-code)" for a detailed list of qualifiers.—
pageinteger否The page number of the results to fetch. For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."1
sortenum (indexed)否**This field is closing down.** Sorts the results of your query. Can only be `indexed`, which indicates how recently a file has been indexed by the GitHub search infrastructure. Default: [best match](https://docs.github.com/rest/search/search#ranking-search-results)—
orderenum (desc | asc)否**This field is closing down.** Determines whether the first search result returned is the highest number of matches (`desc`) or lowest number of matches (`asc`). This parameter is ignored unless you provide `sort`. desc
per_pageinteger否The number of results per page (max 100). For more information, see "[Using pagination in the REST API](https://docs.github.com/rest/using-the-rest-api/using-pagination-in-the-rest-api)."30

调用示例

复制请求代码,查看对应的返回示例。

POST/agent-api/v1/tool/executeX-Api-Key
请求代码request.sh
curl --request POST \
  --url 'https://agentearth.ai/agent-api/v1/tool/execute?tool_name=ae_github_search_code' \
  --header "X-Api-Key: $AGENTEARTH_API_KEY" \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "params": {
    "per_page": 5,
    "q": "PaddleOCR(lang= repo:PaddlePaddle/PaddleOCR language:python"
  }
}'
返回示例response.json
JSON部分内容
{
  "incomplete_results": false,
  "items": [
    {
      "git_url": "https://api.github.com/repositories/262296122/git/blobs/4a0a675a3a73802254b0afaaabf9597b58062076",
      "html_url": "https://github.com/PaddlePaddle/PaddleOCR/blob/dab3fe35379033fdcb2d0e9572fac0b36c9a9ebf/tests/pipelines/test_ocr.py",
      "name": "test_ocr.py",
      "path": "tests/pipelines/test_ocr.py",
      "repository": {
        "archive_url": "https://api.github.com/repos/PaddlePaddle/PaddleOCR/{archive_format}{/ref}",
        "assignees_url": "https://api.github.com/repos/PaddlePaddle/PaddleOCR/assignees{/user}",
        "blobs_url": "https://api.github.com/repos/PaddlePaddle/PaddleOCR/git/blobs{/sha}",
        "id": 262296122,
        "name": "PaddleOCR",
        "url": "https://api.github.com/repos/PaddlePaddle/PaddleOCR"
      },
      "url": "https://api.github.com/repositories/262296122/contents/tests/pipelines/test_ocr.py?ref=dab3fe35379033fdcb2d0e9572fac0b36c9a9ebf"
    }
  ],
  "total_count": 1
}

返回示例仅展示部分内容,不代表完整响应;复制内容为合法 JSON。