Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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#

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
```

>
>
> Info
>

> 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