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 C#
https://github.com/antoniosubasic/aoc.api
advent-of-code aoc api
Last synced: about 1 month ago
JSON representation
a simple Advent of Code API written in C#
- Host: GitHub
- URL: https://github.com/antoniosubasic/aoc.api
- Owner: antoniosubasic
- License: gpl-3.0
- Created: 2023-07-29T10:20:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-31T05:38:59.000Z (5 months ago)
- Last Synced: 2024-07-31T07:13:42.119Z (5 months ago)
- Topics: advent-of-code, aoc, api
- Language: C#
- Homepage: https://www.nuget.org/packages/AoCAPI
- Size: 63.5 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Version](https://img.shields.io/nuget/v/AoCAPI)](https://www.nuget.org/packages/AoCAPI)
[![Downloads](https://img.shields.io/nuget/dt/AoCAPI)](https://www.nuget.org/packages/AoCAPI)a simple [Advent of Code](https://adventofcode.com) API written in C# - also checkout the [Rust version](https://github.com/antoniosubasic/aoc_api)
## Documentation
- [Add NuGet package](#add-nuget-package)
- [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 NuGet package
```bash
dotnet add package AoCAPI
``````csharp
using AoC.API;
```
# Session initialization
```csharp
var client = new Session("session cookie", int year, int day); // Initializes a new Session instance
``````csharp
var client = new Session("session cookie", string input, Regex pattern); // 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
```csharp
string inputText = await client.GetInputTextAsync(); // Retrieves the input text of the AoC puzzle
string[] inputLines = await client.GetInputLinesAsync(); // Retrieves the input lines of the AoC puzzle
```
## Get sample input
```csharp
string sampleInputText = await client.GetSampleInputTextAsync(int nth); // Retrieves the nth sample input text of the AoC puzzle
string[] sampleInputLines = await client.GetSampleInputLinesAsync(int nth); // Retrieves the nth sample input lines of the AoC puzzle
```
## Get achieved stars
```csharp
Dictionary achievedStars = await client.GetAllStarsAsync(); // Retrieves each year's number of stars earned (key: year, value: stars)
```
## Submit answer
```csharp
Response response = await client.SubmitAnswerAsync(int part, object answer); // 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