mkly mkly - 1 year ago 166
Git Question

GitHub Api download zip or tarball link

There was a good link here about how the zip/tarball string is created

When I download a zip from github, what is the hex string at the end of the file name represent?

But I'm looking at the GitHub APIv3 and I was curious if I'm missing something.

  1. Is there a way to get the zip/tarball link via an API call?

  2. If not, is there a way I can build that string without using the git binary or library? Meaning, can I use various API calls to pull out th data a need and assemble to URL I need?

I know the second question is a little unreasonable for stackoverflow and this is a bit of a fun project for me, so I would prefer on the second question if you just kind of nudged me in the right direction as opposed to throwing down a code snippet. Or just told me if it was possible.

Answer Source

You can wget your way out of the GitHub repo to get a tar file (archive):

wget --no-check-certificate

# better, if the certificate authorities are present:

will get you a file named 'master' from the user 'User''s repo 'repo'.

The updated V3 API url is:
# two possibilities for fomat:

# from github example:
$curl -L > octokit.tar.gz

You can then tar xpvf master, getting the full archive.
It will create a directory following the naming convention described in the question you mentioned.

No git binary is needed to get an archive from GitHub, thanks to their download service "Nodeload".