What is the difference between blob_url, raw_url and contents_url in the GitHub API?

The GitHub API documentation shows the following sample response to an API call.

  "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"
    }
  ]

Now I want to consume the contents of individual response files.
 Which of the 3 links should I choose from

  • blub_url
  • raw_url
  • contents_url

What are the differences? What is intended for what purpose?

+4
source share
1 answer

content_urlone (from repo get content API ) supports custom media type

application/vnd.github.VERSION.raw
application/vnd.github.VERSION.html

raw_url is the label for the first of these media types.

blob_url , git, .

+2

Source: https://habr.com/ru/post/1628427/


All Articles