Skip to main content

A command-line tool and library to upload files to Zenodo.

Project description

Zenodo Command-Line Uploader

PyPI version License: MIT PyPI - Python Version CI/CD Status

A flexible tool to upload files to Zenodo, available as both a command-line utility and an importable Python library.

This tool supports pre-flight checks for file sizes, uploading multiple files, rich metadata, and an option to save as a draft for manual review before publishing. It can be easily integrated into automated workflows.

Features

  • Upload multiple files to a single Zenodo record.
  • Set rich metadata including title, author, affiliation, and keywords.
  • Automatically filter out files that exceed a specific size limit.
  • Check total upload size against a limit before starting.
  • Option to upload to the Zenodo Sandbox for testing.
  • Option to save the upload as a draft instead of publishing immediately.
  • Usable as both a standalone CLI tool and a Python library.

Installation

You can install the tool directly from PyPI:

pip install zenodo-uploader

Getting a Zenodo Access Token

This tool requires a Personal Access Token to interact with your Zenodo account.

1. For the Main Zenodo Site (Production)

  1. Log in to https://zenodo.org.
  2. Navigate to your Applications settings by clicking your email in the top-right corner, then selecting "Applications", or go directly to: https://zenodo.org/account/settings/applications/.
  3. Scroll down to the "Personal access tokens" section and click "New token".
  4. Give the token a descriptive name (e.g., my-cli-uploader).
  5. In the Scopes list, you must select the following permissions:
    • deposit:write: Allows creating new records and uploading files.
    • deposit:actions: Allows publishing the records.
  6. Click the "Create" button.
  7. Important: Zenodo will show you the token only once. Copy it immediately and save it in a secure place.

2. For the Zenodo Sandbox (for Testing)

The process is identical, but you must perform it on the Sandbox website. Tokens from the main site and the sandbox are not interchangeable.

  1. Log in to https://sandbox.zenodo.org.
  2. Go to the Sandbox Applications settings: https://sandbox.zenodo.org/account/settings/applications/.
  3. Follow steps 3-7 from the production guide above to create a sandbox-specific token.

Usage

As a Command-Line Tool

Here is an example of how to use the command to upload two files as a draft to the Zenodo sandbox.

zenodo-upload \
--token "YOUR_SANDBOX_TOKEN_HERE" \
--file-paths ./report.pdf ./dataset.zip \
--title "My Research Project Results" \
--author "Doe, John" \
--description "This record contains the final report and raw data for my research project." \
--affiliation "University of Science" \
--keywords "research" "data-analysis" "python" \
--version "v1.0" \
--sandbox
--no_publish
  • Note: By default, the tool saves the upload as a draft. Use the --publish flag to publish immediately.

For a full list of all available options, run:

zenodo-upload --help

As a Python Library

You can also import and use the core upload function directly in your Python scripts for automation.

from zenodo_uploader import upload
import os

# Create some dummy files for the example
os.makedirs("data", exist_ok=True)
with open("data/report.txt", "w") as f:
    f.write("This is a test report.")
with open("data/results.csv", "w") as f:
    f.write("col1,col2\n1,2")

# Your Zenodo sandbox token
MY_TOKEN = "PASTE_YOUR_SANDBOX_TOKEN_HERE"
MY_FILES = ["data/report.txt", "data/results.csv"]

try:
    # Call the upload function
    response_data = upload(
        token=MY_TOKEN,
        file_paths=MY_FILES,
        title="My Automated Dataset",
        author="Script, Python",
        description="This upload was performed programmatically using the library.",
        sandbox=True,          # Use the sandbox for testing
        no_publish=True,       # IMPORTANT: Leave as a draft by default
        affiliation="Automation University",
        keywords=["api", "python", "automation"],
        version="1.0.1"
    )
    print("\n--- Library Call Successful ---")
    print(f"Draft created with ID: {response_data.get('id')}")
    print(f"Review it here: {response_data.get('links', {}).get('latest_draft_html')}")

except SystemExit as e:
    # The upload function will call sys.exit(1) on a critical error.
    # You can catch this in your script to handle failures gracefully.
    print(f"\nUpload failed with exit code: {e.code}")

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zenodo_uploader-0.1.1.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zenodo_uploader-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file zenodo_uploader-0.1.1.tar.gz.

File metadata

  • Download URL: zenodo_uploader-0.1.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for zenodo_uploader-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f3615018893da0a98ba76c69bb42a5896d936501320e4eef1d5c346d34a0c8f5
MD5 33970be3f41c8a5af2cbdcc70742a934
BLAKE2b-256 df28612a3473fc7320bcb5e364c702b7beb88aea9461669e34562fabcf8efaa8

See more details on using hashes here.

Provenance

The following attestation bundles were made for zenodo_uploader-0.1.1.tar.gz:

Publisher: publish-to-pypi.yml on wangleiofficial/zenodo-uploader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file zenodo_uploader-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for zenodo_uploader-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0a88df4e90cfa2995e0c624409a8eecf7d914b9cc5062aa7d277de710cf873f
MD5 69121d668d3752c7e6ad43d17b0d531f
BLAKE2b-256 e0bf100273bdbf38dc0ab481853580121e1514f2eb526b43b0c6fa267f16f0c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for zenodo_uploader-0.1.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on wangleiofficial/zenodo-uploader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page