Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antoniosubasic/aoc_api
a simple Advent of Code API written in Rust
https://github.com/antoniosubasic/aoc_api
advent-of-code aoc api
Last synced: 2 months ago
JSON representation
a simple Advent of Code API written in Rust
- Host: GitHub
- URL: https://github.com/antoniosubasic/aoc_api
- Owner: antoniosubasic
- License: gpl-3.0
- Created: 2024-07-29T18:39:02.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-10-23T13:14:28.000Z (3 months ago)
- Last Synced: 2024-11-18T14:57:25.354Z (2 months ago)
- Topics: advent-of-code, aoc, api
- Language: Rust
- Homepage: https://crates.io/crates/aoc_api
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Version](https://img.shields.io/crates/v/aoc_api)](https://crates.io/crates/aoc_api)
[![Downloads](https://img.shields.io/crates/d/aoc_api)](https://crates.io/crates/aoc_api)a simple [Advent of Code](https://adventofcode.com) API written in Rust - also checkout the [C# version](https://github.com/antoniosubasic/AoC.API)
## Documentation
- [Add Crate](#add-crate)
- [Session initialization](#session-initialization)
- [Features](#features)
- [Get input](#get-input)
- [Get sample input](#get-sample-input)
- [Get achieved stars](#get-achieved-stars)
- [Submit answer](#submit-answer)
# Add Crate
```bash
cargo add aoc_api
``````rust
use aoc_api::Session;
```
# Session initialization
```rust
let client = Session::new("session cookie": String, year: u16, day: u8); // Initializes a new Session instance
``````rust
let client = Session::new("session cookie": String, input: String, pattern: Regex); // Initializes a new Session instance
```>
>
>
>
> The Regex overload needs to have a regex group named "year" and a group named "day".
>
How to name Regex groups
>
How to obtain session cookie
# Features
## Get input
```rust
let input_text: Result> = client.get_input_text().await; // Retrieves the input text of the AoC puzzle
let input_lines: Result, Box> = client.get_input_lines().await; // Retrieves the input lines of the AoC puzzle
```
## Get sample input
```rust
let sample_input_text: Result> = client.get_sample_input_text(nth: u8).await; // Retrieves the nth sample input text of the AoC puzzle
let sample_input_lines: Result, Box> = client.get_sample_input_lines(nth: u8).await; // Retrieves the nth sample input lines of the AoC puzzle
```
## Get achieved stars
```rust
let achieved_stars: Result, Box> = client.get_all_stars().await; // Retrieves each year's number of stars earned (key: year, value: stars)
```
## Submit answer
```rust
let response: Result> = client.submit_answer(part: u8, answer: &str).await; // Submits an answer to part 1 or 2 of the AoC puzzle. Returns a response type with a success status and a cooldown period
```
*credits to:*
> [Max](https://github.com/Mqxx) - markdown info icons
> [Monday Morning Haskell](https://mmhaskell.com/) - documentation on how to obtaining session cookie
> [Developer.Mozilla](https://developer.mozilla.org) - documentation on how to name Regex groups