#steam #image #query-parameters #api #api-bindings

steamgriddb_api

Rust 对 steamgriddb.com API 的客户端

5 个不稳定版本

0.3.1 2022 年 6 月 10 日
0.3.0 2022 年 5 月 12 日
0.2.1 2022 年 5 月 12 日
0.2.0 2021 年 9 月 15 日
0.1.3 2021 年 8 月 27 日

#16 in #images

29 每月下载量

MIT/Apache

66KB
1.5K SLoC

steamgriddb.com 的 Rust 客户端

此项目是 steamgriddb api 的包装器,用 Rust 编写。

入门

开始使用客户端是最简单的方法。

use steamgriddb_api::Client;
use steamgriddb_api::query_parameters::QueryType::Grid;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new("my_auth_key");
    let games = client.search("Celeste").await?;
    let first_game = games.iter().next().ok_or("No games found")?;
    assert_eq!("Celeste", first_game.name);
    let images = client.get_images_for_id(first_game.id, &Grid(None)).await?;
    Ok(())
 }

客户端使用 reqwest 包调用 API,并使用 serde 包解析结果。

如果您想使用不同的方式调用 API,则可以使用库而不使用客户端。

use steamgriddb_api::images::*;
use steamgriddb_api::query_parameters::*;
let url = get_images_by_platform_ids_url("https://www.steamgriddb.com/api/v2", &Platform::Steam, &["107500", "107510"], &QueryType::Grid(None));

使用身份验证密钥

在上面的示例中,客户端被赋予了一个 "my_auth_key",您需要将此字符串替换为您自己的密钥。您可以在此处获取密钥:https://www.steamgriddb.com/profile/preferences/api

进度

此包目前仅支持从 steamgriddb api 获取数据。上传将在以后的版本中提供。

依赖项

~4–18MB
~245K SLoC