Shikimori Rust

Crate version Tests License

Shikimori Rust - An efficient Rust library serving as a wrapper for the Shikimori API 🦾

| 📖 Documentation | | ------------------------------------------ |

Installation

Install shikimori from crates.io. Add the following line to your Cargo.toml file's dependencies section:

toml shikimori = "0.1.0"

Or you can add with cargo

sh cargo add shikimori

Usage

You should also use querygen to simplify your life, it is available at the link. Get the schema at URL https://shikimori.me/api/graphql

```rs use chrono::{DateTime, Utc};

use shikimori::client::ClientBuilder; use shikimori::cynic::QueryBuilder;

use shikimori::graphql::anime::AnimeKind; use shikimori::graphql::types::EntityOrder; use shikimori::graphql::scalars::StatusString; use shikimori::graphql::schema;

[derive(cynic::QueryVariables, Debug)]

pub struct AnimesQueryVariables { pub page: i32, pub status: StatusString, 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 nextepisodeat: Option>, pub url: String, }

[tokio::main]

async fn main() { let client = ClientBuilder::new().build();

let response = client
    .query(AnimesQuery::build(AnimesQueryVariables {
        page: 1,
        status: StatusString::new("ongoing"),
        order: EntityOrder::Popularity,
    }))
    .await;

dbg!(&response);

}

// Ok( // GraphQlResponse { // data: Some( // AnimesQuery { // animes: [ // Anime { // id: Id( // "21", // ), // franchise: Some( // "onepiece", // ), // episodes: 0, // kind: Some( // Tv, // ), // nextepisodeat: Some( // 2023-09-10T00:30:00Z, // ), // url: "https://shikimori.me/animes/21-one-piece", // }, // Anime { // id: Id( // "51009", // ), // franchise: Some( // "jujutsukaisen", // ), // episodes: 23, // kind: Some( // Tv, // ), // nextepisodeat: Some( // 2023-09-07T14:56:00Z, // ), // url: "https://shikimori.me/animes/51009-jujutsu-kaisen-2nd-season", // }, // ], // }, // ), // errors: None, // }, // ) ```