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§
- Used to specify the sort behaviour of the
Client::crates()
method. - Used to specify the sort behaviour of the
Client::crates()
method. - Asynchronous client for the crates.io API.
- Changes made to a create
Version
- Crate author names.
- Additional crate author metadata.
- A crate category.
- A Rust crate published to crates.io.
- Download data for all versions of a
Crate
. - Additional data for crate downloads.
- Links to individual API endpoints that provide crate details.
- Full data for a crate.
- Full data for a crate listing.
- Options for the crates method of the client.
- Builder that enables easy construction of a
CratesQuery
. - List of dependencies of a crate.
- A crate dependency. Specifies the crate and features.
- Crate downloads that don’t fit a particular date. Only required for old download data.
- Complete information for a crate.
- Complete information for a crate version.
- A keyword available on crates.io.
- Pagination information.
- Error returned when a resource could not be found.
- Crate owners.
- Error returned when a resource is not accessible.
- Full list of reverse dependencies for a crate (version).
- Single reverse dependency (aka a dependent) of a crate.
- Summary for crates.io.
- A synchronous client for the crates.io API.
- A crates.io user.
- A
Crate
version. - Download data for a single crate version.
- Links to API endpoints providing extra data for a crate version.
Enums§
- Errors returned by the api client.
- Used to specify the sort behaviour of the
Client::crates()
method.