Skip to main content

Quality Gate StatusDOI

Pynodo -- manage your Zenodo depositions

Python wrapper for Zenodo REST API for working with Zenodo depositions and files.

Installation

pip install pynodo

Usage

Zenodo access token with write scope is necessary to access depositions and files. Separate token is neccessary for zenodo sandbox environment. Sandbox can be switched by setting sandbox=True when initiating pynodo instance.

  • Depositions can be accessed using pynodo.Depositions class.

  • Files in a deposition can be accessed using pynodo.DepositionFiles class.

  • Depositions.create and DepositionFiles.files return namedtuple and list of namedtuples, respectively. Other functions return either json response or status code (delete).

  • Actions (e.g. publish, new version, edit) are not implemented.

Working with Depositions

pynodo allows listing, creating, retrieving, updating and deleting of depostions.

  • Create zenodo (sandbox) instance
import pynodo
import os

zen = pynodo.Depositions(access_token=os.environ["ZENODO_SANDBOX_PAT"], sandbox=True)
  • List user depositions
depos = zen.list(params={"size": 50})
  • Create a new deposition with some metadata
data = {
    "metadata": {
        "title": "My first upload",
        "upload_type": "poster",
        "description": "This is my first upload",
        "creators": [{"name": "Päll, Taavi", "affiliation": "UT"}],
    }
}
new_depo = zen.create(data=data)
  • Retrieve deposition info
ret_depo = zen.retrieve(deposition=new_depo.id)
  • Update deposition metadata
updates = {
    "metadata": {
        "title": "Modified upload",
        "upload_type": "dataset",
        "description": "This is updated upload",
        "creators": [
            {"name": "Päll, Taavi", "affiliation": "UT"},
            {"name": "Sus, Scrofa", "affiliation": "Mets"},
        ],
    }
}
updated_depo = zen.update(deposition=new_depo.id, data=updates)
  • Delete deposition (status code 204 shows success)
zen.delete(new_depo.id)

Working with DepositionFiles

pynodo allows listing, uploading, downloading and deleting of files in a deposition.

  • Create zenodo (sandbox) instance
import pynodo
import os
zen = pynodo.Depositions(access_token=os.environ["ZENODO_SANDBOX_PAT"], sandbox=True)
  • Create new deposition
new_depo = zen.create()
  • Retrive deposition
ret_depo = zen.retrieve(deposition=new_depo.id)
  • Create new instance for listing files
zen_files = pynodo.DepositionFiles(
    deposition=new_depo.id,
    access_token=os.environ["ZENODO_SANDBOX_PAT"],
    sandbox=True,
)
  • Upload file (second argument with new file name is optional)
zen_files.upload("tests/upload.txt", "uploaded_file.txt")
  • List files in deposition
files = zen_files.files
  • Download file from deposition (second argument with download folder is optional)
zen_files.download("uploaded_file.txt", "tmp")
  • Delete file (status code 204 shows success)
zen_files.delete("uploaded_file.txt")

Release files for pynodo 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pynodo 0.2.2
File Size Uploaded
pynodo-0.2.2.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pynodo 0.2.2
File Interpreter ABI Platform
pynodo-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / pynodo-0.2.2.tar.gz

Download URL pynodo-0.2.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
76c75e824f570edad803272c25a11192c8b8189a575885b53bf4fe162798e655
BLAKE2b-256 checksum
How to use checksums
8215f1771c6854b60473ea3e10ffb17ccfe45d13056552f2a65c829ed58c82a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / pynodo-0.2.2-py3-none-any.whl

Download URL pynodo-0.2.2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
345982ab3c3265757dbe15989f8d6f77fe4b6fa12ec4b8376411bcc173289af6
BLAKE2b-256 checksum
How to use checksums
cde6ac0062c7fda3d68bf4febfa2ffb2c0c42b40582abdda1e7cd2ddcc72b132
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page