This project is a basic ASP.NET Core minimal API demonstrating how to build a simple API with in-memory data and minimal code.
- Implements two GET endpoints:
/games– returns all games as JSON/games/{id}– returns a single game by ID or 404 if not found
- Uses a simple in-memory list of game objects
- Includes Swagger/OpenAPI support for interactive API documentation and testing
- .NET 8 SDK
- Recommended: Visual Studio Code or Visual Studio 2022+
-
Clone the repository: git clone https://github.com/YourUsername/YourRepoName.git cd YourRepoName
-
Restore dependencies: dotnet restore
-
Run the project: dotnet run
-
Open your browser and navigate to: http://localhost:PORT/games & http://localhost:PORT/games/id
This opens the Swagger UI where you can explore and test the API endpoints interactively.
GET /games– Retrieves all available games.GET /games/{id}– Retrieves a game by its integer ID.
Example responses:
{ "id": 1, "name": "Chess", "genre": "Strategy" }, { "id": 2, "name": "Pandemic", "genre": "Cooperative" } ]
Program.cs– Main entry point defining API routes and Swagger configuration.Game.cs– Model representing game data.games.http- Fetch the data from the host with defined or preferred methods.
This project helped me practice:
- Building minimal APIs with ASP.NET Core
- Implementing RESTful API endpoints
- Using in-memory collections for quick prototyping
- Integrating Swagger for live API documentation and testing
This is a learning project. Feel free to fork, open issues, or suggest improvements!
Learning ❤️ by [PRaveenkumar-here]