从GitHub API调用starred_at到stargazers

时间:2015-03-31 19:07:32

标签: api curl github

也可以收集GitHub API docs say创建时间戳:

  

您还可以通过Accept标题传递以下自定义内容类型,找出创建星标的时间。

当我这样做时,我没有得到starred_at标记:

url --header "Accept: application/vnd.github.v3.star+json" -i https://api.github.com/repos/basho-labs/puppet-riak/stargazers

HTTP/1.1 200 OK
Server: GitHub.com
Date: Tue, 31 Mar 2015 18:59:31 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 29317
Status: 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 53
X-RateLimit-Reset: 1427831425
Cache-Control: public, max-age=60, s-maxage=60
ETag: "5fac5a4065248d5bf7aa87361239ca51"
Vary: Accept
X-GitHub-Media-Type: github.v3; param=star; format=json
Link: <https://api.github.com/repositories/5506317/stargazers?page=2>; rel="next", <https://api.github.com/repositories/5506317/stargazers?page=2>; rel="last"
X-XSS-Protection: 1; mode=block
X-Frame-Options: deny
Content-Security-Policy: default-src 'none'
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-Scopes, X-Poll-Interval
Access-Control-Allow-Origin: *
X-GitHub-Request-Id: 4926F860:5D3F:23A8CBA:551AEE93
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
X-Content-Type-Options: nosniff
Vary: Accept-Encoding
X-Served-By: a241e1a8264a6ace03db946c85b92db3

[
  {
    "login": "seancribbs",
    "id": 1772,
    "avatar_url": "https://avatars.githubusercontent.com/u/1772?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/seancribbs",
    "html_url": "https://github.com/seancribbs",
    "followers_url": "https://api.github.com/users/seancribbs/followers",
    "following_url": "https://api.github.com/users/seancribbs/following{/other_user}",
    "gists_url": "https://api.github.com/users/seancribbs/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/seancribbs/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/seancribbs/subscriptions",
    "organizations_url": "https://api.github.com/users/seancribbs/orgs",
    "repos_url": "https://api.github.com/users/seancribbs/repos",
    "events_url": "https://api.github.com/users/seancribbs/events{/privacy}",
    "received_events_url": "https://api.github.com/users/seancribbs/received_events",
    "type": "User",
    "site_admin": false
  },

......等等。

我的语法是否关闭?

1 个答案:

答案 0 :(得分:3)

该语句在List repositories being starred API端点的文档中进行,该端点获取给定用户(GET /users/:username/starred)的已加星标的存储库,而不是List Stargazers端点(GET /repos/:owner/:repo/stargazers),显示已加星标特定存储库的用户:

  

列出使用星标创建时间戳

加星标的存储库      

您还可以通过Accept标头传递以下自定义内容类型来了解星星的创建时间。

Accept: application/vnd.github.v3.star+json

它适用于GET /users/:username/starred

curl --header "Accept: application/vnd.github.v3.star+json" -i \
    https://api.github.com/users/:user/starred

HTTP/1.1 200 OK
Server: GitHub.com
Date: Tue, 31 Mar 2015 19:32:24 GMT
Content-Type: application/json; charset=utf-8
Status: 200 OK
...

[
  {
    "starred_at": "2015-02-13T18:33:22Z",
    ...
  }
]