Skip to content

Instantly share code, notes, and snippets.

@slint
Created April 15, 2019 08:54
Show Gist options
  • Save slint/d47fe5628916d14b8d0b987ac45aeb66 to your computer and use it in GitHub Desktop.
Save slint/d47fe5628916d14b8d0b987ac45aeb66 to your computer and use it in GitHub Desktop.
Zenodo restricted access REST API usage
# Let's assume you have received via email the secret link:
# https://zenodo.org/record/123456?token=<LONG-TOKEN-HERE>
# Make a curl request, but store the cookies in a file:
$ curl --cookie-jar zenodo-cookies.txt "https://zenodo.org/record/123456?token=<LONG-TOKEN-HERE>"
...HTML output...
# Use the cookie file to make subsequent requests to the api:
$ curl --cookie zenodo-cookies.txt "https://zenodo.org/api/records/123456"
{
"files": [
{
"bucket": "123456789-1234-1234-1234-8d74f6fd429b",
"checksum": "md5:2482b60c080287d7c0e32886d02e06d9",
"key": "data.zip",
"links": {
"self": "https://zenodo.org/api/files/123456789-1234-1234-1234-8d74f6fd429b/data.zip"
},
"size": 2649,
"type": "zip"
}
],
"metadata": { ... }
...
}
# Download the file using the cookie file:
curl --cookie zenodo-cookies.txt "https://zenodo.org/api/files/123456789-1234-1234-1234-8d74f6fd429b/data.zip" > data.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment