If you would like to help the project, pull requests and suggestions are always welcome :)
This crate is using cargo-features so your project compiles only code related to the endpoint you'll be using.
If you're querying only games
and characters
endpoint, Cargo.toml
should look like this:
toml
[dependencies]
igdb = { "0.1.0", default-features = false, features = ["game", "character"]}
Unless you want the entire codebase from the crate containing all endpoits methods and structs
add this to your Cargo.toml
:
toml
[dependencies]
igdb = "0.1.0"
You can read how to retrieve those credentials here. With Twitch Access Token and Twitch Client ID in hands, we can bring IGDB API wrapper into scope like this: ```rust // Along with the wrapper, bring the endpoint Structs to scope so your code knows the return type of the Vector use igdb::{APIWrapper, models::Game, models::Character}; use std::env;
fn main() { // Using stored environment variables to unwrap our credentials let accesstoken = env::var("TWITCHACCESSTOKEN").unwrap(); let clientid = env::var("TWITCHCLIENTID").unwrap();
// Authenticating with our API wrapper let apiwrapper = APIWrapper::new(&accesstoken, &client_id).unwrap();
// Using the API wrapper methods to query for Zelda games
// Here we are expecting a vector of Game struct, so we used the imported Struct.
let zeldagames: Vec
// Using the API wrapper methods to query for Characters named Mario
// Here we are expecting a vector of Character struct.
let charactersnamedmario: Vec
This example used **environment variables** to store the Twitch retrieved credentials, and then accessing with the rust standard feature
std::env`. In your personal project, you can manage these credentials as you please.