coc.rs
A Clash of Clans API wrapper written in rust!
Key Features
- Asynchronous code
- Entire coverage of Clash of Clans API
- Email and password Login
- Ability to login with multiple accounts to handle many concurrent requests
- API Events to track changes
- Clash of Stats support
Getting Started
Installing
Add the version from here in your Cargo.toml
[]
= "0.7.3"
Alternatively with cargo add
$ cargo add coc-rs --features=all
Quick Example
async
Error Handling
async
Basic Events
First a struct should be created that will implement the trait EventHandler
,
this is similar to how the serenity discord library does event handling.
;
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
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.
Features
To Enable the cos
feature (to use the Clash of Stats API), add this to your Cargo.toml
[]
= { = "0.7.3", = ["cos"] }
To Enable the extra
feature (which gives you extra tools), add this to your Cargo.toml
[]
= { = "0.7.3", = ["extra"] }
Or for both...
To Enable the cos
feature, add this to your Cargo.toml
[]
= { = "0.7.3", = ["all"] }
- Alternately with
cargo add
$ cargo add coc-rs --features cos # or extra...or all (you get it)
Tests
src/lib.rs
contains examples as tests for every endpoint.
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.