Crates.io | pokemon-tcg-sdk |
lib.rs | pokemon-tcg-sdk |
version | 0.3.0 |
source | src |
created_at | 2022-01-11 17:10:58.719884 |
updated_at | 2022-01-24 00:54:40.006869 |
description | Pokémon TCG SDK is a rust wrapper around the Pokémon TCG API located at pokemontcg.io |
homepage | |
repository | https://github.com/mattoni/pokemon-tcg-sdk-rust |
max_upload_size | |
id | 512338 |
size | 40,011 |
This is the Pokémon TCG SDK Rust implementation. It is a wrapper around the Pokémon TCG API of pokemontcg.io.
[dependencies]
pokemon-tcg-sdk = "0.3.0"
// This method fails for the same reasons a reqwest::ClientBuilder would fail (TLS, system config)
// or if your API key contains invalid characters for a header.
let client = Client::with_api_key("YOUR_API_KEY")?;
let client = Client::default();
let card = client.get_card(GetCardRequest::new("base1-1")).await;
match card {
// Card
Ok(c) => println!("{:?}", c),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
let client = Client::default();
let cards = client.search_cards(SearchCardsRequest::new("name:celebi")).await;
match cards {
// Vec<Card>
Ok(c) => println!("{:?}", c),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
// You can also construct a SearchCardsRequest with more parameters
let search_request = SearchCardsRequest {
query: Some(String::from("name:celebi")),
page: Some(10),
page_size: None,
order_by: None,
}
let client = Client::default();
let cards = client.get_all_cards().await;
match cards {
// Vec<Card>
Ok(c) => println!("{:?}", c),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
let client = Client::default();
let set = client.get_set(GetSetRequest::new("base1")).await;
match set {
// Set
Ok(s) => println!("{:?}", s),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
let client = Client::default();
let sets = client.search_sets(SearchSetsRequest::new("series:base")).await;
match sets {
// Vec<Set>
Ok(s) => println!("{:?}", s),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
// You can also construct a SearchSetsRequest with more parameters
let search_request = SearchSetsRequest {
query: Some(String::from("series:base")),
page: Some(2),
page_size: None,
order_by: None,
}
let client = Client::default();
let sets = client.get_all_sets().await;
match sets {
// Vec<Set>
Ok(s) => println!("{:?}", s),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
let client = Client::default();
let types = client.get_supertypes().await;
match types {
// Vec<String>
Ok(c) => println!("{:?}", c),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
let client = Client::default();
let types = client.get_subtypes().await;
match types {
// Vec<String>
Ok(c) => println!("{:?}", c),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
let client = Client::default();
let types = client.get_types().await;
match types {
// Vec<String>
Ok(c) => println!("{:?}", c),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}
let client = Client::default();
let types = client.get_rarities().await;
match types {
// Vec<String>
Ok(c) => println!("{:?}", c),
// Will be a 'ClientError' enum
Err(e) => println!("{:?}", e),
}