https://github.com/thud/codeforces-api
A rust crate implementation of the Codeforces web API + testcase input fetcher.
https://github.com/thud/codeforces-api
codeforces codeforces-api competitive-programming rust-crate
Last synced: 6 days ago
JSON representation
A rust crate implementation of the Codeforces web API + testcase input fetcher.
- Host: GitHub
- URL: https://github.com/thud/codeforces-api
- Owner: thud
- License: mit
- Created: 2021-01-30T15:44:07.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-02T18:42:20.000Z (about 5 years ago)
- Last Synced: 2025-12-13T23:56:31.728Z (4 months ago)
- Topics: codeforces, codeforces-api, competitive-programming, rust-crate
- Language: Rust
- Homepage: https://crates.io/crates/codeforces-api
- Size: 68.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# codeforces-api
A rust crate for interfacing with Codeforces resources with authentication.
It provides the full functionality of the
[Codeforces API](https://codeforces.com/apiHelp) as well as the ability to
fetch testcases for a given problem.
# Usage
```rust
use codeforces_api::requests::{CFBlogEntryCommand, CFAPIRequestable};
use codeforces_api::responses::CFResult;
fn main() {
// This is equivalent to the Codeforces `blogEntry.view` API method.
let x = CFBlogEntryCommand::View {
blog_entry_id: 82347,
};
// The `.get(..)` method on API commands returns a result with either
// an error or an `Ok(CFResult)`.
match x.get("", "") {
Ok(CFResult::CFBlogEntry(blog_entry)) => {
assert_eq!(blog_entry.id, 82347);
println!("Your blog entry: {:?}", blog_entry);
},
Ok(_) => {
// In very rare cases, an unexpected type may be returned by
// `.get()`. If this happens, then you may wish to throw a
// custom error.
panic!("`.get()` returned an unexpected type.");
}
Err(e) => {
// Errors returned are of a custom Error type. This could be
// returned if, for example, an invalid API key/secret was used
// or if there was no internet connection.
panic!("something failed {:?}", e);
}
}
}
```
[Docs](https://docs.rs/codeforces-api) |
[Crate](https://crates.io/crates/codeforces-api) |
[License](LICENSE)