A command-line tool and library to upload files to Zenodo.
Project description
Zenodo Command-Line Uploader
A flexible and powerful tool to upload files to Zenodo, available as both a command-line utility and an importable Python library.
This tool supports creating new depositions, updating existing drafts, listing records, and interactive configuration. It is designed for both manual use and integration into automated workflows.
Features ✨
- Create new depositions with multiple files.
- List all your existing records (both drafts and published).
- Update existing drafts by adding files or modifying metadata.
- Interactive setup command (
configure) to easily create your configuration file. - Configuration file support (
.zenodo.toml) for persistent settings (tokens, author info). - Progress bars during file uploads for an improved user experience.
- Professional logging system with a
--verboseoption for debugging. - Usable as both a standalone CLI tool and a Python library.
Installation
You can install the tool directly from PyPI:
pip install zenodo-uploader
Configuration (Recommended)
For the best experience, run the interactive setup command first. It will securely store your tokens and default information.
zenodo-upload configure
This will create a .zenodo.toml file in your home directory. The tool will automatically use the settings from this file.
Here is an example of the .zenodo.toml file structure:
[default]
author = "Your Name"
affiliation = "Your University"
[tokens]
production = "YOUR_PRODUCTION_TOKEN_HERE"
sandbox = "YOUR_SANDBOX_TOKEN_HERE"
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: https://zenodo.org/account/settings/applications/.
- Click "New token".
- Give the token a name and select the
deposit:writeanddeposit:actionsscopes. - Click "Create" and copy the token immediately.
2. For the Zenodo Sandbox (for Testing)
The process is identical on the Sandbox website: https://sandbox.zenodo.org/account/settings/applications/. Sandbox and production tokens are not interchangeable.
Command-Line Usage
The tool now uses subcommands: configure, list, upload, and update.
configure: Interactive Setup
Creates the .zenodo.toml configuration file for you.
# Run the interactive setup wizard
zenodo-upload configure
list: Listing Your Records
Lists all depositions (drafts and published) in your account.
# List records from the sandbox environment
zenodo-upload list --sandbox
upload: Creating a New Record
Creates a new deposition and uploads files. By default, it creates a draft.
# Create a new draft on the sandbox using values from your config file
zenodo-upload upload \
--file-paths ./report.pdf ./dataset.zip \
--title "My Research Project Results" \
--description "This record contains the final report and raw data." \
--sandbox
update: Modifying a Draft
Updates an existing draft deposition.
# Add a new file to an existing draft in the sandbox
zenodo-upload update 1234567 --add-file ./new_figure.png --sandbox
For a full list of options for any subcommand, use --help, for example: zenodo-upload upload --help.
As a Python Library
You can import and use the core functions directly in your Python scripts. The package exposes upload, list_depositions, and update_deposition.
Example 1: Creating a New Upload
from zenodo_uploader import upload
MY_TOKEN = "PASTE_YOUR_SANDBOX_TOKEN_HERE"
metadata = {
"title": "My Automated Dataset",
"author": "Script, Python",
"description": "This upload was performed programmatically.",
}
# This creates a new draft in the sandbox
response_data = upload(
token=MY_TOKEN,
file_paths=["./data/report.txt"],
metadata=metadata,
sandbox=True,
publish=False
)
print(f"Draft created: {response_data.get('links', {}).get('latest_draft_html')}")
Example 2: Listing and Updating a Draft
from zenodo_uploader import list_depositions, update_deposition
TOKEN = "YOUR_SANDBOX_TOKEN_HERE"
# First, list depositions to find a draft
print("--- Listing depositions ---")
all_deps = list_depositions(token=TOKEN, sandbox=True)
drafts = [d for d in all_deps if not d['submitted']]
if not drafts:
print("No drafts found to update.")
else:
draft_id = drafts[0]['id']
print(f"\n--- Found draft with ID {draft_id}. Updating it... ---")
# Create a new file to add
with open("update_log.txt", "w") as f:
f.write("This file was added during an update.")
# Call the update function to add the file and change the description
updated_dep = update_deposition(
token=TOKEN,
deposition_id=draft_id,
files_to_add=["update_log.txt"],
metadata={"description": "Description updated programmatically."},
sandbox=True
)
print("\n--- Update Successful ---")
print(f"Review the updated draft at: {updated_dep.get('links', {}).get('latest_draft_html')}")
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.3.tar.gz.
File metadata
- Download URL: zenodo_uploader-0.1.3.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4e0a58599855be4dd26e43bb013e230ab106a8c8e6d5af43705d91d2513e635
|
|
| MD5 |
9de71978b1e650bc93692fb9d11ea2e5
|
|
| BLAKE2b-256 |
48da3d5aac037da6aa379265c6d06029394bcce6586d424797b80a98bccc5920
|
Provenance
The following attestation bundles were made for zenodo_uploader-0.1.3.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.3.tar.gz -
Subject digest:
f4e0a58599855be4dd26e43bb013e230ab106a8c8e6d5af43705d91d2513e635 - Sigstore transparency entry: 375963983
- Sigstore integration time:
-
Permalink:
wangleiofficial/zenodo-uploader@e60c3c9c5675660de456058d0cfa34bcecfe8d3b -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/wangleiofficial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e60c3c9c5675660de456058d0cfa34bcecfe8d3b -
Trigger Event:
release
-
Statement type:
File details
Details for the file zenodo_uploader-0.1.3-py3-none-any.whl.
File metadata
- Download URL: zenodo_uploader-0.1.3-py3-none-any.whl
- Upload date:
- Size: 9.2 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 |
e39a03c4d818c2cfa28a124c5b01c1bbce4be9317af1eec08a7687079c60b322
|
|
| MD5 |
df9f07a27d60208ea4591ff301b47f23
|
|
| BLAKE2b-256 |
b603c863b3a43d3454329297a8fe7a98217267ad7c36fa7d26c4d6e50820e8f5
|
Provenance
The following attestation bundles were made for zenodo_uploader-0.1.3-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.3-py3-none-any.whl -
Subject digest:
e39a03c4d818c2cfa28a124c5b01c1bbce4be9317af1eec08a7687079c60b322 - Sigstore transparency entry: 375963987
- Sigstore integration time:
-
Permalink:
wangleiofficial/zenodo-uploader@e60c3c9c5675660de456058d0cfa34bcecfe8d3b -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/wangleiofficial
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e60c3c9c5675660de456058d0cfa34bcecfe8d3b -
Trigger Event:
release
-
Statement type: