Skip to content

Exercise Minimal APIs Video Game Characters

Exercise Minimal APIs – Video Game Characters

Assignment

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"
}

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


GET /vg-characters

Returns all available characters.

Filters

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

GET /vg-characters/{id}

Returns a specific character by ID.


POST /vg-characters

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


PUT /vg-characters/{id}

Update a specific character by ID.


DELETE /vg-characters/{id}

Delete a character by ID.


Storing data

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


Request and response data

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.


Tests

  • 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.