Usage - BAChapin/Advent-of-Code-2020-Server GitHub Wiki

I designed this API to be very simple, but I highly recommend using PostMan or a similar client to use it properly. You can of course create an interface to interact with the API, please feel free.

Heroku

This project is hosted on Heroku at: https://adventofcode2020.herokuapp.com

If you want to test the raw API via PostMan or a similar client I will refer to the above link as [Base] moving forward.

Usage

I have designed the API with a basic routing scheme that follows the pattern below:

Getting Answers

[Base]/day/<day #>/part1

or

[Base]/day/<day #>/part2

Please follow the PostMan instructions below in order to get your answers.

Getting JSON

[Base]/day/<day #>/json

Each day's challenge is different and requires different representation. Each JSON response with have the raw data in the form of an array which can easily be parsed into a large string or text file. It will also contain the answers for the given data it generates in whatever form makes the most sense.

Getting RAW

[Base]/day/<day #>/raw

This RAW text representation is just a randomly generated string with carriage returns between each piece of data (that you would normally find in the array of the JSON). This is represented exactly as the input data from Advent of Code is presented.

PostMan Usage

Each of the routes are GET routes. So be sure to set the route method to GET.

Header Tab

After changing your route method you'll need to change or add a key-value pair in the header tab. The following is exactly what you need to add/modify.

KEY VALUE
Content-Type text/plain

Body Tab

Go into the body tab and select the RAW option, and paste your input data into the body section.

Possible Outputs

RAW Answer - If nothing was modified, and the input was directly from Advent of Code, it should return the correct and appropriate result1.

JSON - A JSON object of whatever day's challenge, randomly generated every time the url is called.

RAW Text - A multi-line string of whatever day's challenge, randomly generated every time the url is called.

Possible Errors

Bad Request - This error can happen if the data that was sent into the body could not properly be parsed. So if the route expects a list of numbers separated by new lines, it will fail parsing and return a Bad Request error.

Not Found - In the situation that the data parsed correctly by in trying to find the answer, and there is no default answer, the route will return a Not Found error.

1At present all the "answers" to the challenges have been integers, so the return type from each API request will be an integer. If this changes moving throughout the Advent the appropriate type will be used as the return type.

⚠️ **GitHub.com Fallback** ⚠️