internetarchive-rs 0.1.0

Async Rust client for Internet Archive item metadata, search, uploads, metadata updates, and downloads.
Documentation

internetarchive-rs

CI codecov crates.io docs.rs License

internetarchive-rs is an async Rust client for working with Internet Archive items. It supports public metadata reads, advanced search, authenticated uploads and deletes, metadata updates, public downloads, and higher-level create or upsert workflows, while staying close to the real Internet Archive APIs instead of hiding them behind a made-up abstraction.

InternetArchiveClient is the main entrypoint. Use SearchQuery for advanced search, ItemMetadata and UploadSpec to describe uploads, and PatchOperation with MetadataTarget for exact low-level metadata writes. If you want higher-level item creation or updates, use InternetArchiveClient::publish_item and InternetArchiveClient::upsert_item.

Read Example

use internetarchive_rs::InternetArchiveClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = InternetArchiveClient::new()?;
    let item = client.get_item_by_str("xfetch").await?;
    let pdf = item.file("xfetch.pdf").expect("file exists");
    assert_eq!(pdf.name, "xfetch.pdf");

    Ok(())
}

Search Example

use internetarchive_rs::{InternetArchiveClient, SearchQuery, SortDirection};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = InternetArchiveClient::new()?;
    let results = client
        .search(
            &SearchQuery::builder("collection:opensource AND mediatype:texts")
                .field("identifier")
                .field("title")
                .rows(5)
                .sort("publicdate", SortDirection::Desc)
                .build(),
        )
        .await?;

    for doc in results.response.docs {
        let identifier = doc.identifier().expect("identifier field requested");
        let title = doc.title().unwrap_or("<untitled>");
        println!("{identifier}: {title}");
    }

    Ok(())
}

Publish Example

use internetarchive_rs::{
    InternetArchiveClient, ItemIdentifier, ItemMetadata, MediaType, PublishRequest, UploadSpec,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = InternetArchiveClient::from_env()?;
    let request = PublishRequest::new(
        ItemIdentifier::new("my-demo-item-2026-04-18")?,
        ItemMetadata::builder()
            .mediatype(MediaType::Texts)
            .title("internetarchive-rs example")
            .description_html("<p>Created from Rust</p>")
            .collection("opensource")
            .language("eng")
            .build(),
        vec![UploadSpec::from_path("artifact.txt")?],
    );

    let outcome = client.upsert_item(request).await?;
    println!(
        "created={}, uploaded={:?}",
        outcome.created, outcome.uploaded_files
    );

    Ok(())
}

Low-Level Metadata Patch Example

use internetarchive_rs::{
    InternetArchiveClient, ItemIdentifier, MetadataTarget, PatchOperation,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = InternetArchiveClient::from_env()?;
    let identifier = ItemIdentifier::new("my-demo-item-2026-04-18")?;

    client
        .apply_metadata_patch(
            &identifier,
            MetadataTarget::Metadata,
            &[PatchOperation::replace("/title", "Updated title")],
        )
        .await?;

    Ok(())
}

Authentication

InternetArchiveClient::new() is enough for public metadata reads, searches, and downloads.

Authenticated write helpers use LOW auth credentials and read these standard environment variables: INTERNET_ARCHIVE_ACCESS_KEY and INTERNET_ARCHIVE_SECRET_KEY. You can create S3 credentials from the official Internet Archive API key page at https://archive.org/account/s3.php.