zenodo-rs 0.1.2

Rust client for Zenodo deposition workflows, record retrieval, and artifact downloads.
Documentation

zenodo-rs

CI codecov crates.io docs.rs License

Async Rust client for core Zenodo workflows.

It covers deposition create/update/publish flows, safe draft reuse versus newversion, published-record lookup, latest-version resolution, and downloads behind a small typed API for automation and CI jobs built on top of the Zenodo REST API.

Start Here

Install

[dependencies]
zenodo-rs = "0.1"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Optional features:

  • checksums: validate Zenodo md5: checksums when downloading to a path
  • native-tls: use reqwest with native-tls instead of the default rustls-tls

Read Example

use zenodo_rs::ZenodoClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ZenodoClient::from_sandbox_env()?;
    let record = client.get_record_by_doi_str("10.5281/zenodo.123").await?;
    let _ = record.id;

    Ok(())
}

Publish Example

use zenodo_rs::{
    AccessRight, Auth, DepositMetadataUpdate, DepositionId, FileReplacePolicy, UploadSpec,
    UploadType, ZenodoClient,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ZenodoClient::new(Auth::new("token"))?;
    let metadata = DepositMetadataUpdate::builder()
        .title("Example dataset")
        .upload_type(UploadType::Dataset)
        .description_html("<p>Example upload</p>")
        .creator_named("Doe, Jane")
        .access_right(AccessRight::Open)
        .build()?;

    let published = client
        .publish_dataset_with_policy(
            DepositionId(42),
            &metadata,
            FileReplacePolicy::ReplaceAll,
            vec![UploadSpec::from_path("artifact.tar.gz")?],
        )
        .await?;
    let _ = published.record.id;

    Ok(())
}

Authentication

  • ZENODO_TOKEN is the standard env var for the production service at zenodo.org.
  • ZENODO_SANDBOX_TOKEN is the sandbox equivalent for sandbox.zenodo.org.
  • Write flows usually need deposit:write and deposit:actions.

Notes

Public download APIs use Zenodo IDs and selectors rather than raw URLs, and uploads require a known content length. For Zenodo-side behavior and token scopes, see the Zenodo developer docs.