# Shikimori Rust
> **Shikimori Rust** - An efficient Rust library serving as a wrapper for the Shikimori API 🦾
| 📖 [Documentation](https://docs.rs/shikimori) |
| ------------------------------------------ |
## Installation
Install [shikimori from crates.io](https://crates.io/crates/shikimori). Add the following line to your `Cargo.toml` file's dependencies section:
```toml
shikimori = "0.4"
```
Or you can add with cargo
```sh
cargo add shikimori
```
## Usage
You should also use [querygen](https://generator.cynic-rs.dev) to simplify your life, it is available at the link. Get the schema at URL `https://shikimori.one/api/graphql`
```rs
use chrono::{DateTime, Utc};
use shikimori::client::ClientBuilder;
use shikimori::cynic::{self, QueryBuilder};
use shikimori::graphql::anime::AnimeKind;
use shikimori::graphql::scalars::{AnimeStatusString, PositiveInt};
use shikimori::graphql::schema;
use shikimori::graphql::types::EntityOrder;
#[derive(cynic::QueryVariables, Debug)]
pub struct AnimesQueryVariables {
pub page: PositiveInt,
pub status: AnimeStatusString,
pub order: EntityOrder,
}
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query", variables = "AnimesQueryVariables")]
pub struct AnimesQuery {
#[arguments(censored: false, page: $page, status: $status, order: $order)]
pub animes: Vec,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct Anime {
pub id: cynic::Id,
pub franchise: Option,
pub episodes: i32,
pub kind: Option,
pub next_episode_at: Option>,
pub url: String,
}
#[tokio::main]
async fn main() {
let client = ClientBuilder::new().build();
let response = client
.query(AnimesQuery::build(AnimesQueryVariables {
page: PositiveInt::new(1u32),
status: AnimeStatusString::new("ongoing"),
order: EntityOrder::Popularity,
}))
.await;
dbg!(&response);
}
// Ok(
// GraphQlResponse {
// data: Some(
// AnimesQuery {
// animes: [
// Anime {
// id: Id(
// "21",
// ),
// franchise: Some(
// "one_piece",
// ),
// episodes: 0,
// kind: Some(
// Tv,
// ),
// next_episode_at: Some(
// 2023-09-10T00:30:00Z,
// ),
// url: "https://shikimori.one/animes/21-one-piece",
// },
// Anime {
// id: Id(
// "51009",
// ),
// franchise: Some(
// "jujutsu_kaisen",
// ),
// episodes: 23,
// kind: Some(
// Tv,
// ),
// next_episode_at: Some(
// 2023-09-07T14:56:00Z,
// ),
// url: "https://shikimori.one/animes/51009-jujutsu-kaisen-2nd-season",
// },
// ],
// },
// ),
// errors: None,
// },
// )
```
In the `build.rs` file with feature `register-graphql-schema` enabled
```rs
fn main() {
shikimori::graphql::register_schema();
}
```