Crate crates_io_api[][src]

Expand description

API client for crates.io.

It aims to provide an easy to use and complete client for retrieving information about Rust’s crate ecosystem.

Both a AsyncClient and a SyncClient are available, providing either a Futures based or a blocking interface.

Please read the official crates.io Crawler Policy before using this crate.

Due to this policy, you must specify both a user agent and a desired rate limit delay when constructing a client. See SyncClient::new and AsyncClient::new for more information.

Examples

Print the most downloaded crates and their non-optional dependencies:

use crates_io_api::{SyncClient, Error};

fn list_top_dependencies() -> Result<(), Error> {
    // Instantiate the client.
    let client = SyncClient::new(
         "my-user-agent (my-contact@domain.com)",
         std::time::Duration::from_millis(1000),
    )?;
    // Retrieve summary data.
    let summary = client.summary()?;
    for c in summary.most_downloaded {
        println!("{}:", c.id);
        for dep in client.crate_dependencies(&c.id, &c.max_version)? {
            // Ignore optional dependencies.
            if !dep.optional {
                println!("    * {} - {}", dep.id, dep.version_id);
            }
        }
    }
    Ok(())
}

Structs

AsyncClient

Asynchronous client for the crates.io API.

Authors
AuthorsMeta
AuthorsResponse
Category
Crate
CrateLinks
CrateResponse
CratesResponse
Dependencies
Dependency
Downloads
DownloadsMeta
ExtraDownloads
FullCrate
FullVersion
Keyword
ListOptions

Options for the crates method of the client.

Meta

Pagination information.

NotFound
Owners
ReverseDependencies
ReverseDependency
Summary
SyncClient

A synchronous client for the crates.io API.

User
Version
VersionDownloads
VersionLinks

Enums

Error
Sort

Used to specify the sort behaviour of the Client::crates() method.