Welcome to the Online Book Store API! This API provides a comprehensive set of endpoints to interact with the Online Book Store system. It allows users to browse, search, and manage books, as well as perform user authentication and authorization. Whether you are a developer integrating with the API or a user looking to explore the functionalities, this guide will help you get started.
The Online Book Store API is built using the following technologies and frameworks:
- C# and .NET technologies
- ASP.NET Core
- Entity Framework Core
- JWT (JSON Web Tokens) for authentication
- Microsoft Identity for user management
- Microsoft SQL Server for the database
Make sure you have the necessary prerequisites and dependencies installed before proceeding with the setup.
This project was developed by:
- Sarah Hamdi
- Farida Momoh
To use the Online Book Store API, follow the steps below:
-
Clone the repository
git clone <repository-url>
-
Install dependencies
cd online-book-store-api
dotnet restore
- Configure the database
- Open the
appsettings.json
file. - Modify the
ConnectionStrings:DefaultConnection
value to match your SQL Server connection string. - Modify the
JwtConfig:Secret
value to use a secure secret key for JWT token generation. It is recommended to generate a strong random key of sufficient length (e.g., 256 bits). - You can use a tool like a password manager or a cryptographic library to generate a secure secret key.
- Apply database migrations
dotnet ef database update
- Run the API
dotnet run
- Explore the API endpoints
- The API is now running locally on
http://localhost:5000
. - Use a tool like Postman or cURL to make HTTP requests to the available endpoints. Refer to the API Documentation for detailed information about the endpoints and their usage.
- User Authentication
- Register a new user by making a
POST
request to/authentication/register
with the required user details. - Obtain a JWT token by making a
POST
request to/authentication/login
with the user's login credentials. The token will be included in the response. - Include the obtained JWT token in the
Authorization
header for authenticated requests. Example:Authorization: Bearer <token>
- Manage Books
- Use the appropriate endpoints to perform CRUD operations on books, such as creating, updating, deleting, and retrieving books by various criteria.
- Ensure you have the necessary authorization roles to access specific endpoints. Admin privileges are required for certain operations.
- Shopping Cart
- Add books to the shopping cart using the
/book/add-to-cart/{id}
endpoint. - View the contents of the shopping cart using the
/book/view-cart
endpoint. - Remove books from the shopping cart using the
/book/delete-from-cart/{id}
endpoint.
- Error Handling
- The API includes robust error handling mechanisms to provide meaningful error messages and responses in case of exceptions or invalid requests.
- Logging
- Logging is implemented to capture relevant information for debugging and troubleshooting purposes. Check the log files for any issues or helpful insights.
That's it! You can now start using the Online Book Store API. If you have any questions or need further assistance, please reach out to the collaborators mentioned above.
Happy exploring and happy coding!