2 releases

0.1.1 Feb 15, 2021
0.1.0 Feb 14, 2021

#16 in #crates-io

Download history 13/week @ 2024-07-27 200/week @ 2024-08-03 23/week @ 2024-08-10 1/week @ 2024-08-17 16/week @ 2024-09-07 15/week @ 2024-09-14 13/week @ 2024-09-21 4/week @ 2024-09-28 11/week @ 2024-10-12 20/week @ 2024-10-19 2/week @ 2024-10-26 118/week @ 2024-11-02 6/week @ 2024-11-09

147 downloads per month
Used in cns

MIT license

37KB
728 lines

consecrates

Tiny but virtuous crates.io API client.

The main aim of this library is to provide an easy way to query crates information without bringing in too many dependencies.

It's loosely modeled after the crates_io_api crate. Main differences include:

  • about 70% cut in the number of dependencies
  • no async
  • no multi-request client methods like full_crate or all_crates
  • ability to use category and keyword specifiers for querying crates
  • ability to convert simple string composite queries such as api category=web keyword=crates sort=update into valid query objects

Using

Paste the following into your project's Cargo.toml file:

consecrates = "0.1.1"

Create a new client and issue a query:

let client = Client::new("my_app (github.com/me/me_app)");
let crates = client
    .get_crates(Query {
        string: Some("net".to_string()),
        category: Some(Category::GameDevelopment),
        sort: Some(Sorting::RecentUpdates),
        ..Default::default()
    })
    .expect("failed getting crates");
println!("{:?}", crates);

Crawler policy

Please consult the official crawler policy before using this library. Rate limiting is fixed at the lowest tolerated value. When creating a client you will need to input a proper user-agent string.

Dependencies

~13MB
~321K SLoC