Download project at commit level via REST Api

How do I go about downloading a given project at a certain commit point via the REST Api in zip format preferable or is that not possible?

Yes, this is absolutely possible. You just need to specify the SHA of the commit as a parameter, when you send the GET request. This SHA is completely optional. If omitted, the archive will contain a snapshot at the latest commit of the default branch.

You can even try this from your browser, to understand how it works.

For example:

https://gitlab.example.com/api/v3/projects/:project_id/repositories/archive.zip?sha=9c7d9a232dd5a318a36c3c5050f70d7484ceea8d&private_token=my_private_token

You don’t need to specify the full SHA for this to work. However, it’s probably safer to use all 40 characters, especially when working with a project with a long history and many commits.

The optional SHA parameter is also detailed in the docs for the repositories end-point here:
http://doc.gitlab.com/ce/api/repositories.html#get-file-archive

Don’t forget to include the desired file extension. If you want a zip file, like you mentioned, you’ll need to specify archive.zip (as in the above example).

Thanks Mark! That was exactly what I was looking for, I must have just missed the optional SHA part.

Hi sladd,

I’m glad you found a resolution to your issue. How did you save the archive stream to disk?