Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is codeload.github.com different to api.github.com?

I was browsing the next.js repository and noticed this function that downloads and extracts a template from GitHub, with tar:

export async function downloadAndExtractExample(
  root: string,
  name: string
): Promise<void> {
  return await promisePipe(
    got.stream('https://codeload.github.com/zeit/next.js/tar.gz/canary'),
    tar.extract({ cwd: root, strip: 3 }, [`next.js-canary/examples/${name}`])
  )
}

I searched on StackOverflow and I only found this:

  • GitHub Api download zip or tarball link

That's a thread explaining how you can pull a tar.gz from GitHub, but there is no mention of the "codeload" subdomain. How is it different to "api"?

like image 795
Paul Razvan Berg Avatar asked Feb 12 '20 12:02

Paul Razvan Berg


People also ask

What is Codeload GitHub com?

The GitHub API provides the best way to get a URL to download an archive. When you make a GET request on that URL, it will redirect you to a URL on codeload.github.com . codeload is the service which provides archives for download and it's on its own domain for caching reasons.

Is there an API for GitHub?

Learn about GitHub's APIs to extend and customize your GitHub experience. There are two stable versions of the GitHub API: the REST API and the GraphQL API.

What is API GitHub Com users?

The Users API allows to get public and private information about the authenticated user. Users. Get the authenticated user. Update the authenticated user. List users.

What is GitHub API URL?

The GitHub developer's site: https://developer.github.com/v3/, shows this URL: https://api.github.com.


1 Answers

The GitHub API provides the best way to get a URL to download an archive. When you make a GET request on that URL, it will redirect you to a URL on codeload.github.com. codeload is the service which provides archives for download and it's on its own domain for caching reasons.

While it's possible to use the codeload URL directly, you generally want to use the API URL, since it handles things like authentication more gracefully, and the codeload URLs for private repositories are generally ephemeral.

like image 90
bk2204 Avatar answered Oct 23 '22 03:10

bk2204