igdb_rs/
lib.rs

1//! # Non-Official Internet Game Database Api Client written in Rust
2//!
3//! With igdb-rs you can easily retrieve video game related information such as:
4//!
5//! Games, Franchises, Videos, Artworks, Covers, Screenshots, Release Dates, Multiplayer Options, Game Engines, Websites and much more!.
6//!
7//! Use out of the box client methods or build your own queries to retrieve the exact data that you are looking for.
8//!
9//!
10//! ## Links
11//!  [Repository]
12//!
13//!  [README]
14//!
15//!  [IGDB Site]
16//!
17//!  [IGDB Api]
18//!
19//! [Repository]: https://github.com/CarlosLanderas/igdb-rs
20//! [IGDB Site]: https://github.com/TyOverby/bincode
21//! [IGDB Api]: https://api-docs.igdb.com/#endpoints
22//! [examples]: https://github.com/CarlosLanderas/igdb-rs/tree/master/examples
23//! [README]: https://github.com/CarlosLanderas/igdb-rs/blob/develop/README.md
24//!
25//! ## Code Examples
26//! You can check some code samples here: [examples]
27//!
28//! ## Examples
29//!
30//! **Get game by name**
31//!
32//! ```no_run
33//!use async_std::task;
34//!use igdb_rs::client::IGDBClient;
35//!
36//!task::block_on(async {
37//!    let games_client = IGDBClient::new("user-key").games();
38//!    let games_results = games_client.get_by_name("Borderlands", 10).await.unwrap();
39//!
40//!    for game in games_results {
41//!        println!("Name: {}", game.name);
42//!        println!("Story line: {}", game.storyline);
43//!        println!("Url: {}", game.url);
44//!    }
45//!
46//!   //  Name: The Witcher 3: Wild Hunt - Hearts of Stone
47//!   //  Summary: Hired by the Merchant of Mirrors, Geralt is tasked with overcoming Olgierd von Everec -- a ruthless bandit captain enchanted with the power of immorta ...
48//!   //  Story line: Professional monster slayer is hired to deal with a ruthless bandit captain who possesses the power of immortality.
49//!   //  Url: https://www.igdb.com/games/the-witcher-3-wild-hunt-hearts-of-stone
50//!
51//!})
52//!```
53//!
54//! **Get games by name**
55//!
56//!```no_run
57//!use async_std::task;
58//!use igdb_rs::client::IGDBClient;
59//!
60//!   task::block_on(async {
61//!        let games_client = IGDBClient::new("user-key").games();
62//!        // Get ten first games containing word Borderlands
63//!        let games_results = games_client.get_by_name("Borderlands", 10).await.unwrap();
64//!
65//!        for game in games_results {
66//!            println!("Name: {}", game.name);
67//!            println!("Story line: {}", game.storyline);
68//!            println!("Url: {}", game.url);
69//!        }
70//!
71//!        //        Name: Borderlands: The Pre-Sequel - Lady Hammerlock The Baroness
72//!        //        Story line:
73//!        //            Url: https://www.igdb.com/games/borderlands-the-pre-sequel-lady-hammerlock-the-baroness
74//!        //            Name: Borderlands Legends
75//!        //        Story line:
76//!        //            Url: https://www.igdb.com/games/borderlands-legends
77//!        //            Name: Tales from the Borderlands: Episode 3 - Catch a Ride
78//!        //        Story line:
79//!        //            Url: https://www.igdb.com/games/tales-from-the-borderlands-episode-3-catch-a-ride
80//!        //            Name: Borderlands 2: Game of the Year Edition
81//!
82//!        // Omitted for brevity...
83//!    })
84//!```
85//!
86//! **Game release date**
87//!
88//!```no_run
89//!use async_std::task;
90//!use igdb_rs::client::IGDBClient;
91//!
92//!   task::block_on(async {
93//!        let igdb_client = IGDBClient::new("user-key");
94//!
95//!        let release_client = igdb_client.release_dates();
96//!
97//!       //Get releases for Borderlands3 with id 19164
98//!        let releases = release_client.get_by_game_id(19164, 10).await.unwrap();
99//!
100//!        let platform_client = igdb_client.platforms();
101//!
102//!        for release in releases {
103//!            let platform = platform_client
104//!                .get_first_by_id(release.platform as usize)
105//!                .await
106//!                .unwrap();
107//!
108//!            println!(
109//!                "platform: {} release date: {}",
110//!                platform.name, release.human
111//!            );
112//!        }
113//!
114//!        //  platform: Xbox One release date: 2019-Sep-13
115//!        //  platform: PC (Microsoft Windows) release date: 2019-Sep-13
116//!        //  platform: PlayStation 4 release date: 2019-Sep-13
117//!        //  platform: Google Stadia release date: 2019-Sep-13
118//!    })
119//!```
120//!
121//! **Download Screenshots and Covers for a game**
122//!
123//! ```no_run
124//!
125//!use async_std::task;
126//!use igdb_rs::client::IGDBClient;
127//!use igdb_rs::media_quality::MediaQuality;
128//!
129//!
130//! task::block_on(async {
131//!        let igdb_client = IGDBClient::new("user-key");
132//!        let games_client = igdb_client.games();
133//!        let witcher = games_client.get_first_by_name("Witcher 3").await.unwrap();
134//!
135//!        //Get the first 3 covers for the Witcher 3 game
136//!        let covers_client = igdb_client.covers();
137//!        let covers_response = covers_client.get_by_game_id(witcher.id, 3).await.unwrap();
138//!
139//!        //Get the first 3 screenshots for the Witcher 3 game
140//!        let screenshots_client = igdb_client.screenshots();
141//!        let screenshots_response = screenshots_client
142//!            .get_by_game_id(witcher.id, 3)
143//!            .await
144//!            .unwrap();
145//!
146//!        for (i, cover) in covers_response.iter().enumerate() {
147//!            covers_client
148//!                .download_by_id(
149//!                    cover.id,
150//!                    format!("cover{}.jpg", i),
151//!                    MediaQuality::ScreenshotHuge,
152//!                )
153//!                .await
154//!                .unwrap();
155//!        }
156//!
157//!        for (i, screenshot) in screenshots_response.iter().enumerate() {
158//!            screenshots_client
159//!                .download_by_id(
160//!                    screenshot.id,
161//!                    format!("screenshot{}.jpg", i),
162//!                    MediaQuality::CoverBig,
163//!                )
164//!                .await
165//!                .unwrap();
166//!        }
167//!    })
168//! ```
169//!
170//! **You can read more samples here: [examples]**
171#[macro_use]
172extern crate serde_derive;
173
174type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
175
176mod endpoint_client;
177mod endpoints;
178
179#[macro_use]
180mod client_macros;
181#[macro_use]
182mod media_macros;
183
184pub mod client;
185pub mod extensions;
186pub mod media_helpers;
187pub mod media_quality;
188pub mod model;
189pub mod request_builder;
190pub mod request_filters;