Github API JSON

Github API Json

https://api.github.com/


<pre name="code" class="plain">{
  "current_user_url": "https://api.github.com/user",
  "current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
  "authorizations_url": "https://api.github.com/authorizations",
  "code_search_url": "https://api.github.com/search/code?q={query}{&page,per_page,sort,order}",
  "emails_url": "https://api.github.com/user/emails",
  "emojis_url": "https://api.github.com/emojis",
  "events_url": "https://api.github.com/events",
  "feeds_url": "https://api.github.com/feeds",
  "followers_url": "https://api.github.com/user/followers",
  "following_url": "https://api.github.com/user/following{/target}",
  "gists_url": "https://api.github.com/gists{/gist_id}",
  "hub_url": "https://api.github.com/hub",
  "issue_search_url": "https://api.github.com/search/issues?q={query}{&page,per_page,sort,order}",
  "issues_url": "https://api.github.com/issues",
  "keys_url": "https://api.github.com/user/keys",
  "notifications_url": "https://api.github.com/notifications",
  "organization_repositories_url": "https://api.github.com/orgs/{org}/repos{?type,page,per_page,sort}",
  "organization_url": "https://api.github.com/orgs/{org}",
  "public_gists_url": "https://api.github.com/gists/public",
  "rate_limit_url": "https://api.github.com/rate_limit",
  <strong>"repository_url": "https://api.github.com/repos/{owner}/{repo}",</strong>
  "repository_search_url": "https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}",
  "current_user_repositories_url": "https://api.github.com/user/repos{?type,page,per_page,sort}",
  "starred_url": "https://api.github.com/user/starred{/owner}{/repo}",
  "starred_gists_url": "https://api.github.com/gists/starred",
  "team_url": "https://api.github.com/teams",
  "user_url": "https://api.github.com/users/{user}",
  "user_organizations_url": "https://api.github.com/user/orgs",
  "user_repositories_url": "https://api.github.com/users/{user}/repos{?type,page,per_page,sort}",
  "user_search_url": "https://api.github.com/search/users?q={query}{&page,per_page,sort,order}"
}


 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个Java代码示例,使用GitHub APIGitHub仓库中读取文件内容: ```java import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.Base64; public class GitHubFileReader { public static void main(String[] args) throws IOException { // GitHub API URL String apiUrl = "https://api.github.com/repos/{owner}/{repo}/contents/{path}"; // GitHub repository information String owner = "github"; String repo = "gitignore"; String path = "Java.gitignore"; // Replace placeholders with actual values apiUrl = apiUrl.replace("{owner}", owner) .replace("{repo}", repo) .replace("{path}", path); // Set up HTTP connection URL url = new URL(apiUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setRequestProperty("Accept", "application/vnd.github.v3+json"); // Set up authentication if needed String username = "username"; String token = "token"; String auth = username + ":" + token; byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8)); String authHeaderValue = "Basic " + new String(encodedAuth); connection.setRequestProperty("Authorization", authHeaderValue); // Read response InputStream responseStream = connection.getInputStream(); String response = new String(responseStream.readAllBytes(), StandardCharsets.UTF_8); // Extract content from response int start = response.indexOf("\"content\": \"") + 12; int end = response.indexOf("\",", start); String content = response.substring(start, end); // Decode content String decodedContent = new String(Base64.getDecoder().decode(content), StandardCharsets.UTF_8); // Print content System.out.println(decodedContent); } } ``` 这个代码示例假设你已经有了GitHub API的访问令牌,用于身份验证。如果你没有访问令牌,你需要创建一个并将其传递到HTTP请求中,以便进行身份验证。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值