无法对 GitHub V3 API 中的版本进行分页
Unable to paginate releases in GitHub V3 API
我正在尝试使用 V3 API 在 GitHub 上列出 public 存储库的所有版本。这是我提出的要求:
curl -is -H 'Accept: application/vnd.github.v3+json' \
https://api.github.com/repos/ffmpeg/ffmpeg/releases
我收到的回复 header 在这里:
HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 29 Jan 2016 20:23:15 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 29612
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 19
X-RateLimit-Reset: 1454099558
Cache-Control: public, max-age=60, s-maxage=60
ETag: "947039722a1073c5279a9fd39d00c0bf"
Vary: Accept
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
Vary: Accept-Encoding
X-Served-By: b0ef53392caa42315c6206737946d931
X-GitHub-Request-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
注意到缺少 Link
响应 header?在响应 body 中,我只返回了大约 7 个版本,而且我似乎无法通过手动指定 ?page=N
查询参数来向前或向后分页。
对于某些背景,FFmpeg 有大约 226 个版本 in its GitHub repository,我只得到其中的 7 个左右,无法通过它们分页。
我在这里做错了什么会限制我从 GitHub v3 API 返回的回复吗?
GitHub 将其专有版本功能与常规 Git 标签合并。您在 ffmpeg 中看到的许多 "releases" 实际上只是标签。
这是一个example of a real release. Note how it contains much more information than a tag does. Despite their web UI showing tags mixed in with releases, GitHub's release API endpoint doesn't include regular tags:
This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the Repository Tags API.
按照 GitHub 的建议使用 tags endpoint 会得到更多结果,并且如您所料包含 Link
header:
curl -is -H 'Accept: application/vnd.github.v3+json' \
https://api.github.com/repos/ffmpeg/ffmpeg/tags
我正在尝试使用 V3 API 在 GitHub 上列出 public 存储库的所有版本。这是我提出的要求:
curl -is -H 'Accept: application/vnd.github.v3+json' \
https://api.github.com/repos/ffmpeg/ffmpeg/releases
我收到的回复 header 在这里:
HTTP/1.1 200 OK
Server: GitHub.com
Date: Fri, 29 Jan 2016 20:23:15 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 29612
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 19
X-RateLimit-Reset: 1454099558
Cache-Control: public, max-age=60, s-maxage=60
ETag: "947039722a1073c5279a9fd39d00c0bf"
Vary: Accept
X-GitHub-Media-Type: github.v3; format=json
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-
Access-Control-Allow-Origin: *
Content-Security-Policy: default-src 'none'
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: deny
X-XSS-Protection: 1; mode=block
Vary: Accept-Encoding
X-Served-By: b0ef53392caa42315c6206737946d931
X-GitHub-Request-Id: XXXXXXXXXXXXXXXXXXXXXXXXXXXX
注意到缺少 Link
响应 header?在响应 body 中,我只返回了大约 7 个版本,而且我似乎无法通过手动指定 ?page=N
查询参数来向前或向后分页。
对于某些背景,FFmpeg 有大约 226 个版本 in its GitHub repository,我只得到其中的 7 个左右,无法通过它们分页。
我在这里做错了什么会限制我从 GitHub v3 API 返回的回复吗?
GitHub 将其专有版本功能与常规 Git 标签合并。您在 ffmpeg 中看到的许多 "releases" 实际上只是标签。
这是一个example of a real release. Note how it contains much more information than a tag does. Despite their web UI showing tags mixed in with releases, GitHub's release API endpoint doesn't include regular tags:
This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the Repository Tags API.
按照 GitHub 的建议使用 tags endpoint 会得到更多结果,并且如您所料包含 Link
header:
curl -is -H 'Accept: application/vnd.github.v3+json' \
https://api.github.com/repos/ffmpeg/ffmpeg/tags