如何获取 GitHub 存储库的描述?

wol*_*m77 6 github github-api

每个GitHub 存储库都有一个描述 字段和一个可选的网站 字段。如何使用AJAX访问(任何 GitHub 存储库的)这些字段?

tej*_*ane 7

Github 提供了用于获取有关存储库的详细信息的 API:

https://api.github.com/repos/<organization>/<project>

例如。https://api.github.com/repos/ruby/ruby

您可以使用简单的 jQuery 来获取您需要的信息:

$.ajax('https://api.github.com/repos/ruby/ruby').done(function(json) { 
   // You can access the description as json.description
   console.log(json.description);       
});
Run Code Online (Sandbox Code Playgroud)