A simple ASP.NET Core Web API project that dynamically fetches a list of books from the Open Library API and allows users to perform CRUD operations on the locally stored collection.
Live Demo :- Click here
- Fetches book data dynamically from the Open Library API on first request.
- Stores the fetched books in a local in-memory collection.
- Supports Create, Read, Update, and Delete (CRUD) operations on the book collection.
- Uses
HttpClientFactoryfor external API calls. - Minimal and clean REST API design.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/books |
Get all books |
| GET | /api/books/{id} |
Get a book by ID |
| POST | /api/books |
Add a new book |
| PUT | /api/books/{id} |
Update an existing book |
| DELETE | /api/books/{id} |
Delete a book |
Replace the above image with your actual demo screenshot.
- .NET 7 SDK or later installed
- An IDE or editor like Visual Studio or VS Code
-
Clone the repository or download the source code.
-
Navigate to the project directory:
cd LearningDotNet -
Restore dependencies and run the project:
dotnet restore dotnet run
-
The API will be available at:
https://localhost:5124 -
Use tools like Postman, curl, or your browser to test the endpoints.
-
Get all books:
curl https://localhost:5124/api/books -k
-
Get a book by ID:
curl https://localhost:5124/api/books/1 -k
-
Add a new book:
curl -X POST https://localhost:5124/api/books -H "Content-Type: application/json" -d \ '{"title":"New Book","author":"Author Name","year":2025}' -k
-
Update a book:
curl -X PUT https://localhost:5124/api/books/1 -H "Content-Type: application/json" -d \ '{"id":1,"title":"Updated Title","author":"Updated Author","year":2024}' -k
-
Delete a book:
curl -X DELETE https://localhost:5124/api/books/1 -k
- ASP.NET Core Web API
- C# 11
- HttpClientFactory
- Open Library API (https://openlibrary.org/developers/api)
- JSON Serialization with System.Text.Json


