Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

download_zenodo_draft.py - Download files from Zenodo draft deposits

Description

This script downloads files from a Zenodo draft deposit using the Zenodo API. It can handle draft deposits that require authentication and provides advanced features like selective downloading and smart resuming.

Usage

python3 tools/download_zenodo_draft.py RECORD_ID [--access-token TOKEN]

Arguments

Examples

# Download all files with access token
python3 tools/download_zenodo_draft.py 123456 --access-token your_token_here

# Show what would be downloaded (dry run)
python3 tools/download_zenodo_draft.py 123456 --sandbox --dry-run

# Download only specific files (use numbers from dry-run output)
python3 tools/download_zenodo_draft.py 123456 --files "1,3,5"
python3 tools/download_zenodo_draft.py 123456 --files "2"

Authentication

Environment Variables

export ZENODO_ACCESS_TOKEN=your_token_here
# or
export ZENODO_TOKEN=your_token_here

.env File Support

Create a .env file with:

ZENODO_ACCESS_TOKEN=your_token_here

(requires python-dotenv: pip install python-dotenv)

Token Priority Order

  1. Command line --access-token argument

  2. ZENODO_ACCESS_TOKEN or ZENODO_TOKEN environment variable

  3. .env file with ZENODO_ACCESS_TOKEN or ZENODO_TOKEN

Features

How It Works

  1. API Connection: Connects to Zenodo API (production or sandbox)

  2. Metadata Fetch: Retrieves metadata for the specified draft deposit

  3. File Validation: Skips files that already exist with matching checksums

  4. Download: Downloads selected files (or all files) to zenodo-RECORD_ID directory

  5. Checksum Storage: Preserves checksums in generated/manifest.zenodo-RECORD_ID.DATE.{sha256,md5}

  6. Metadata Creation: Creates file size metadata in generated/metadata.zenodo-RECORD_ID.txt

Output Structure

zenodo-RECORD_ID/           # Downloaded files
generated/
├── manifest.zenodo-RECORD_ID.DATE.sha256
├── manifest.zenodo-RECORD_ID.DATE.md5
└── metadata.zenodo-RECORD_ID.txt

Getting Access Tokens

You need a Zenodo access token to access draft deposits:

Requirements

Error Handling

This tool is essential for working with unpublished Zenodo deposits in research workflows that require access to draft materials.

Community Request URLs

Draft deposits under community review can be addressed using the request URL:

https://zenodo.org/communities/<community>/requests/<uuid>

The script calls GET /api/requests/{uuid} to resolve the deposit record ID, then proceeds with the normal draft download. An access token is required.

python3.12 tools/download_zenodo_draft.py \
  https://zenodo.org/communities/aeajournals/requests/61cff0cb-b3ca-48aa-bfe6-5b17dc8eb665 \
  --access-token $ZENODO_ACCESS_TOKEN