A command-line tool and library to upload files to Zenodo.
Project description
Zenodo Command-Line Uploader
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)
- Log in to https://zenodo.org.
- 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/.
- Scroll down to the "Personal access tokens" section and click "New token".
- Give the token a descriptive name (e.g.,
my-cli-uploader). - 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.
- Click the "Create" button.
- 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.
- Log in to https://sandbox.zenodo.org.
- Go to the Sandbox Applications settings: https://sandbox.zenodo.org/account/settings/applications/.
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3615018893da0a98ba76c69bb42a5896d936501320e4eef1d5c346d34a0c8f5
|
|
| MD5 |
33970be3f41c8a5af2cbdcc70742a934
|
|
| BLAKE2b-256 |
df28612a3473fc7320bcb5e364c702b7beb88aea9461669e34562fabcf8efaa8
|
Provenance
The following attestation bundles were made for zenodo_uploader-0.1.1.tar.gz:
Publisher:
publish-to-pypi.yml on wangleiofficial/zenodo-uploader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zenodo_uploader-0.1.1.tar.gz -
Subject digest:
f3615018893da0a98ba76c69bb42a5896d936501320e4eef1d5c346d34a0c8f5 - Sigstore transparency entry: 374539286
- Sigstore integration time:
-
Permalink:
wangleiofficial/zenodo-uploader@db35af64f174fc7416fdeea0d7e4bee1937a02dc -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wangleiofficial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@db35af64f174fc7416fdeea0d7e4bee1937a02dc -
Trigger Event:
release
-
Statement type:
File details
Details for the file zenodo_uploader-0.1.1-py3-none-any.whl.
File metadata
- Download URL: zenodo_uploader-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0a88df4e90cfa2995e0c624409a8eecf7d914b9cc5062aa7d277de710cf873f
|
|
| MD5 |
69121d668d3752c7e6ad43d17b0d531f
|
|
| BLAKE2b-256 |
e0bf100273bdbf38dc0ab481853580121e1514f2eb526b43b0c6fa267f16f0c8
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zenodo_uploader-0.1.1-py3-none-any.whl -
Subject digest:
d0a88df4e90cfa2995e0c624409a8eecf7d914b9cc5062aa7d277de710cf873f - Sigstore transparency entry: 374539291
- Sigstore integration time:
-
Permalink:
wangleiofficial/zenodo-uploader@db35af64f174fc7416fdeea0d7e4bee1937a02dc -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/wangleiofficial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@db35af64f174fc7416fdeea0d7e4bee1937a02dc -
Trigger Event:
release
-
Statement type: