GitHub API 中的 blob_url、raw_url 和 contents_url 有什么区别?

Ern*_*nst 5 git api rest json github

GitHub的API文档显示了一个API调用的答案下面的例子。

  "files": [
    {
      "sha": "bbcd538c8e72b8c175046e27cc8f907076331401",
      "filename": "file1.txt",
      "status": "added",
      "additions": 103,
      "deletions": 21,
      "changes": 124,
      "blob_url": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
      "raw_url": "https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
      "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e",
      "patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
    }
  ]
Run Code Online (Sandbox Code Playgroud)

现在我想使用答案的单个文件的内容。
我应该从 3 个链接中选择哪个

  • blub_url
  • 原始网址
  • 内容网址

有什么区别?什么意思是什么目的?

Von*_*onC 3

一个content_url(从repo get content API)支持自定义媒体类型

application/vnd.github.VERSION.raw
application/vnd.github.VERSION.html
Run Code Online (Sandbox Code Playgroud)

raw_url是第一种媒体类型的快捷方式。

只能blob_url看到commits 中的文件,并提供 git 存储库中存储的该文件的内容,没有媒体类型的概念。