Manage Zenodo research projects programmatically using Python
For researchers seeking a user-friendly and compliant open-access repository for their digital artifacts, Zenodo is an excellent choice. This article will walk you through the process of creating a personal access token, installing the `zenodopy` Python package, and using it to interact with Zenodo's API.
**Creating a Personal Access Token**
1. To begin, you'll need to generate a personal access token (PAT) on the Zenodo website. Log into your Zenodo account and navigate to the **Applications** section. 2. Here, you'll find the option to create a new PAT. Generate a token with the necessary scopes/permissions for API access, typically "deposit:actions" and "upload" permissions. 3. Copy this token securely and keep it private, as it should not be shared publicly.
**Installing and Using zenodopy**
The Python package for working with Zenodo API is called `zenodopy`. You can install it via pip:
```bash pip install zenodopy ```
After installing the package, you can use it in your Python scripts:
```python from zenodopy import Zenodo
# Initialize client with personal access token client = Zenodo(token="your_personal_access_token_here")
# Use client methods to interact with Zenodo API ```
**Interacting with Zenodo API**
With the `zenodopy` package, you can perform various tasks such as uploading, downloading, and managing files, as well as listing projects and their associated project IDs.
To upload a file, provide the file path using the `upload_file()` method:
```python client.upload_file('path_to_your_file', 'your_file_name') ```
To download a file, use the `download_file()` method with the file name:
```python client.download_file('your_file_name', 'path_to_save_file') ```
If you wish to upload large or remote datasets, consider using the Zenodo API directly, as the web app may not be suitable for such tasks.
**Managing Projects**
To list all projects and their associated project IDs, use the `list_projects()` method:
```python projects = client.list_projects() ```
To create a new project, you first create a `Client()` object, and then create a project with the required details. To set the project that the `Client()` object is connected to, use the `set_project()` method with the project ID.
**Caution**
Exercise caution when using the Zenodo API to delete a project, as once deleted it cannot be recovered. The Zenodo API function for deleting a project is intentionally hidden to minimize accidental deletions.
**Zenodo's Mission**
Zenodo, operated by CERN, is a general-purpose open-access repository that believes in the FAIR principles: data should be Findable, Accessible, Interoperable, and Reusable. Zenodo is Plan S compliant, making it an ideal choice for researchers seeking open-access repositories to share their work.
[1] Zenodo personal access tokens can be generated on Zenodo’s site for API usage, including for tools like CLI or SDKs that interact with Zenodo. Although `zenodopy` specifics are not detailed in the search results, this is the standard approach for Zenodo API authorization.
Data-and-cloud-computing technology allows for interaction with Zenodo's API using the Python package, enabling researchers to perform tasks like uploading, downloading, and managing files, as well as listing projects and their associated project IDs. To create personal access tokens necessary for API authorization, log into your Zenodo account, navigate to the Applications section, generate a new PAT with necessary scopes/permissions, and keep it private.