| Crates.io | screeps-rust-api |
| lib.rs | screeps-rust-api |
| version | 0.1.1 |
| created_at | 2025-10-24 13:16:56.667208+00 |
| updated_at | 2026-01-09 01:13:25.559514+00 |
| description | Screeps Rust API |
| homepage | https://github.com/lovezhangchuangxin/screeps-rust-api |
| repository | https://github.com/lovezhangchuangxin/screeps-rust-api |
| max_upload_size | |
| id | 1898412 |
| size | 106,463 |
A Rust API client library for the Screeps game.
Currently in rapid development. Many features are still incomplete, stay tuned!
use screeps_rust_api::{ScreepsApi, ScreepsConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ScreepsConfig::new(
Some("your_token".to_string()),
None,
None,
"screeps.com".to_string(),
true,
10,
);
let api = ScreepsApi::new(config);
// Get user info
let user_info = api.get_my_info().await?;
if let Some(user) = user_info.user {
println!("User ID: {}", user._id);
} else {
println!("Failed to get user info (likely invalid token)");
}
// Get room objects
let room_objects = api.get_room_objects("W41S11", "shard3").await?;
if let Some(objects) = room_objects.objects {
println!("Found {} objects in room", objects.len());
} else {
println!("Failed to get room objects");
}
Ok(())
}
For more, see the examples under the examples directory.
get_my_info() - Get current user infoget_my_name() - Get current usernameget_user_info_by_name(username) - Get user info by usernameget_user_info_by_id(id) - Get user info by user IDget_user_rooms(id) - Get all rooms for a given userget_room_objects(room, shard) - Get all objects in a roomget_room_terrain(room, shard) - Get room terrain infoget_room_terrain_encoded(room, shard) - Get encoded room terrain infoget_room_status(room, shard) - Get room statusget_shards() - Get all shard infoget_shard_time(shard) - Get the current game time for a shardauth() - Authenticate and get tokencargo build
cargo test
Note: Some tests require valid Screeps account credentials, which are provided via environment variables.
To run tests requiring authentication, create a .env file with the following variables:
SCREEPS_EMAIL=your_email@example.com
SCREEPS_PASSWORD=your_password
SCREEPS_TOKEN=your_token