Crate crates_io_api

Source
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),
    ).unwrap();
    // 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§

ApiError
Used to specify the sort behaviour of the Client::crates() method.
ApiErrors
Used to specify the sort behaviour of the Client::crates() method.
AsyncClient
Asynchronous client for the crates.io API.
AuditAction
Changes made to a create Version
Authors
Crate author names.
AuthorsMeta
Additional crate author metadata.
Category
A crate category.
Crate
A Rust crate published to crates.io.
CrateDownloads
Download data for all versions of a Crate.
CrateDownloadsMeta
Additional data for crate downloads.
CrateLinks
Links to individual API endpoints that provide crate details.
CrateResponse
Full data for a crate.
CratesPage
Full data for a crate listing.
CratesQuery
Options for the crates method of the client.
CratesQueryBuilder
Builder that enables easy construction of a CratesQuery.
Dependencies
List of dependencies of a crate.
Dependency
A crate dependency. Specifies the crate and features.
ExtraDownloads
Crate downloads that don’t fit a particular date. Only required for old download data.
FullCrate
Complete information for a crate.
FullVersion
Complete information for a crate version.
Keyword
A keyword available on crates.io.
Meta
Pagination information.
NotFoundError
Error returned when a resource could not be found.
Owners
Crate owners.
PermissionDeniedError
Error returned when a resource is not accessible.
ReverseDependencies
Full list of reverse dependencies for a crate (version).
ReverseDependency
Single reverse dependency (aka a dependent) of a crate.
Summary
Summary for crates.io.
SyncClient
A synchronous client for the crates.io API.
User
A crates.io user.
Version
A Crate version.
VersionDownloads
Download data for a single crate version.
VersionLinks
Links to API endpoints providing extra data for a crate version.

Enums§

Error
Errors returned by the api client.
Sort
Used to specify the sort behaviour of the Client::crates() method.