Full-featured crate to interact with Codewars API. Check official documentation for more information about API.
Note
At this moment, Codewars API is minimal and inconsistent. So, you can't to do some things with API and this crate
- Interact with the Codewars REST API
- Get user info
- Get list of completed challenges
- Get list of authored challenges
- Get kata info
- Interact with the Codewars API using webhooks
You can install this crate from Crates.io using Cargo:
$ cargo add codewars-api
At this moment only REST API is supported, webhook support will be added in the future. Import it in your project:
use codewars_api::rest_api::client::RestCodewarsClient;
Then, initialize the client:
let client = RestCodewarsClient::new();
And you can use methods of client:
let user = client.get_user("username").await.unwrap();
let challenges = client.get_completed_challenges("username", 1).await.unwrap();
Tip
If you want to use it in main
function you should install tokio
$ cargo add tokio
And then you can use it in main
function:
use tokio;
use codewars_api::rest_api::client::RestCodewarsClient;
#[tokio::main]
async fn main() {
let client = RestCodewarsClient::new();
let user = client.get_user("username").await.unwrap();
let challenges = client.get_completed_challenges("username", 1).await.unwrap();
}
Documentation for this crate can be found at docs.rs Also, you can see examples of using this crate in examples. To run example clone this repo and run this:
$ cargo run --example <example_name>
For example:
$ cargo run --example print_name
- conemu-progressbar-go - Progress bar for ConEmu for Go
- envfetch - Lightweight crossplatform CLI tool for working with environment variables
- terminal-go - Go library for working with ANSI/VT terminal sequences
- zapret-discord-youtube - Zapret build for Windows for fixing Discord and YouTube in Russia or othher services
Firstly, you should install Git and Rust.
- Create fork of this repo by pressing button on the top of this page.
- Clone your fork
$ git clone https://github.com/username/codewars-api-rs.git
- Go to directory where you cloned repo
$ cd codewars-api-rs
- Create new branch
- Make your changes
- Run tests:
$ cargo test
- Write tests and documentation for your changes
- Format and lint code:
$ cargo fmt
$ cargo clippy
- Commit changes
- Create PR
You can learn more about writing tests in the official documentation.
We test all methods of RestCodewarsClient
struct in doctests.
At this moment, we don't use mock in doctests, so you should add no_run
attribute for doctests, like this:
# Examples
```no_run
use codewars_api::rest_api::client::RestCodewarsClient;
...
```
In unit tests we use mockito
library for mock testing. See it's official documentation for more information. Mocks are stored in tests/mocks
directory. All mocks are from Codewars documentation.