Crates.io | scpsl-api |
lib.rs | scpsl-api |
version | 0.1.0-alpha.10 |
source | src |
created_at | 2021-07-29 10:11:48.123541 |
updated_at | 2021-07-29 17:20:34.359601 |
description | A SCP: Secret Laboratory API wrapper |
homepage | |
repository | https://github.com/trickybestia/scpsl-api |
max_upload_size | |
id | 428683 |
size | 37,929 |
A SCP: Secret Laboratory API wrapper (see official API reference).
use scpsl_api::server_info::{get, RequestParameters, Response};
use std::env::var;
use url::Url;
#[tokio::main]
async fn main() {
let account_id = var("ACCOUNT_ID")
.expect("Expected an account id in the environment")
.parse::<u64>()
.unwrap();
let api_key = var("API_KEY").expect("Expected an account id in the environment");
let parameters = RequestParameters::builder()
.url(Url::parse("https://api.scpslgame.com/serverinfo.php").unwrap())
.id(account_id)
.key(api_key)
.players(true)
.build();
if let Response::Success(response) = get(¶meters).await.unwrap() {
println!(
"Total players on your servers: {}",
response
.servers()
.iter()
.map(|server| server.players_count().unwrap().current_players())
.sum::<u32>()
)
}
}
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in scpsl-api by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.