Skip to content

Exercise Minimal APIs Video Game Characters

Exercise Minimal APIs – Video Game Characters

Section titled “Exercise Minimal APIs – Video Game Characters”

Build a REST API using .NET Minimal APIs.
Your API should manage data about video game characters.

A character is described by these properties:

  • Name
  • Game (the title they come from)
  • Role (hero, villain, sidekick, etc.)
  • Ability (their special power/skill)

For example:

{
"id": 1,
"name": "Mario",
"game": "Super Mario Bros.",
"role": "Hero",
"ability": "Jump Power"
}
{
"id": 2,
"name": "Sephiroth",
"game": "Final Fantasy VII",
"role": "Villain",
"ability": "Supernova"
}
{
"id": 3,
"name": "Pikachu",
"game": "Pokémon",
"role": "Sidekick",
"ability": "Thunderbolt"
}

:::note
In C#, class properties should be written in PascalCase (Id, Name, Game, Role, Ability).
When serialized to JSON, they will automatically be converted to camelCase. :::

The single resource of your API is /vg-characters.
You should support these endpoints:


Returns all available characters.

It should be possible to filter using query parameters:

  • GET /vg-characters?game=Pokémon → all characters from Pokémon
  • GET /vg-characters?role=Hero → all heroes
  • GET /vg-characters?ability=Jump%20Power → characters with the “Jump Power” ability

Returns a specific character by ID.


Insert a new entry into the list of characters.
The API will automatically assign a new ID.


Update a specific character by ID.


Delete a character by ID.


Normally, data is stored in a database.
For this exercise, you can keep it simple: store your characters in memory using a static List.


All requests and responses should be JSON.
Think carefully about which fields are required in requests, and which ones should only be returned in responses.


  • Test manually with Postman.
  • Write automated unit tests for your handlers.
    • Example: Insert a character, fetch it again, then delete it and check that it’s gone.
    • Each endpoint should have at least one test.

For testing, ensure your handlers are accessible to your unit test project. You can follow the structure outlined in Dotnet Minimal APIs#Structuring Example.