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. - Async
Client - Asynchronous client for the crates.io API.
- Audit
Action - Changes made to a create
Version
- Authors
- Crate author names.
- Authors
Meta - Additional crate author metadata.
- Category
- A crate category.
- Crate
- A Rust crate published to crates.io.
- Crate
Downloads - Download data for all versions of a
Crate
. - Crate
Downloads Meta - Additional data for crate downloads.
- Crate
Links - Links to individual API endpoints that provide crate details.
- Crate
Response - Full data for a crate.
- Crates
Page - Full data for a crate listing.
- Crates
Query - Options for the crates method of the client.
- Crates
Query Builder - Builder that enables easy construction of a
CratesQuery
. - Dependencies
- List of dependencies of a crate.
- Dependency
- A crate dependency. Specifies the crate and features.
- Extra
Downloads - Crate downloads that don’t fit a particular date. Only required for old download data.
- Full
Crate - Complete information for a crate.
- Full
Version - Complete information for a crate version.
- Keyword
- A keyword available on crates.io.
- Meta
- Pagination information.
- NotFound
Error - Error returned when a resource could not be found.
- Owners
- Crate owners.
- Permission
Denied Error - Error returned when a resource is not accessible.
- Reverse
Dependencies - Full list of reverse dependencies for a crate (version).
- Reverse
Dependency - Single reverse dependency (aka a dependent) of a crate.
- Summary
- Summary for crates.io.
- Sync
Client - A synchronous client for the crates.io API.
- User
- A crates.io user.
- Version
- A
Crate
version. - Version
Downloads - Download data for a single crate version.
- Version
Links - Links to API endpoints providing extra data for a crate version.