我正在Github上觀看392個知識庫。但是,Github API只返回100.有人知道爲什麼嗎?爲什麼Github API只返回前100個監視存儲庫?
https://github.com/api/v2/json/repos/watched/trivektor
我正在Github上觀看392個知識庫。但是,Github API只返回100.有人知道爲什麼嗎?爲什麼Github API只返回前100個監視存儲庫?
https://github.com/api/v2/json/repos/watched/trivektor
您需要使用page
參數手動分頁。如果可用,HTTP響應頭將告訴你下一頁和最後一頁。檢查標題:
X-Next
X-Last
例子:
curl -D- https://github.com/api/v2/json/repos/watched/trivektor
HTTP/1.1 200 OK
Server: nginx/1.0.4
Date: Sat, 22 Oct 2011 08:24:45 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 60
ETag: "c597e396e9f17b91c5c5a7e462ba954f"
X-Next: https://github.com/api/v2/json/repos/watched/trivektor?page=2
X-Last: https://github.com/api/v2/json/repos/watched/trivektor?page=5
現在第2頁:
curl -D- https://github.com/api/v2/json/repos/watched/trivektor?page=2
HTTP/1.1 200 OK
Server: nginx/1.0.4
Date: Sat, 22 Oct 2011 08:28:08 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 60
ETag: "c57d0e97e2062672cb3771467cf2abc7"
X-Next: https://github.com/api/v2/json/repos/watched/trivektor?page=3
X-Last: https://github.com/api/v2/json/repos/watched/trivektor?page=5
X-Frame-Options: deny
X-RateLimit-Remaining: 58
X-Runtime: 353ms
Content-Length: 44966
Cache-Control: private, max-age=0, must-revalidate
,最後一個:
curl -D- https://github.com/api/v2/json/repos/watched/trivektor?page=5
HTTP/1.1 200 OK
Server: nginx/1.0.4
Date: Sat, 22 Oct 2011 08:28:30 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 200 OK
X-RateLimit-Limit: 60
ETag: "11ce44ebc229eab0dc31731b39e10dcf"
X-Frame-Options: deny
X-RateLimit-Remaining: 57
X-Runtime: 93ms
Content-Length: 7056
Cache-Control: private, max-age=0, must-revalidate
很常見的API的限制響應對象的大小,以防止異常值。鑑於它是返回一個整數,這表明這是設計。我沒有看到他們在他們的文檔中討論分頁,所以它可能只是一個硬帽。無論哪種方式,你應該只能ping github。