coc.rs
A Clash of Clans API wrapper written in rust!
Key feature
- Asynchronous code
- Entire coverage of Clash of clans API
- Email and Password Login
- Multiple Accounts Login to handle concurrent requests
- API Events!
- Clash of Stats support
Getting Started
Installing
Add the version from here in your Cargo.toml
[]
= "x.x.x"
Alternatively with cargo add
$ cargo add coc-rs
Quick Example
async
How to Handle Errors
async
Basic Events
First we need to make a Event handler struct, that will implement the trait EventHandler
;
Next in the main function, we will create the main function, login and add the Player and clan tags we want to keep pulling the data from API.
async
Features
To Enable cos
feature, add this to your Cargo.toml
[]
= { = "x.x.x", = ["cos"] }
- Alternately with
cargo add
$ cargo add coc-rs --features cos
Note: Each endpoint has a different cache refresh time. Each event will be fired at the exact time of new cache data in the API.
Possible Error Code
400 -> BadRequestException 403 -> AuthException 404 -> NotFoundException 429 -> RateLimitException 503 -> MaintenanceException
Note
src/test.rs
& src/test_cos.rs
contains examples for every endpoint in more detail.
Contributing
Contributing is fantastic and much welcomed! If you have an issue, feel free to open an issue and start working on it.
Disclaimer
This content is not affiliated with, endorsed, sponsored, or specifically approved by Supercell and Supercell is not responsible for it. For more information see Supercell'S Fan Content Policy.