- Overview
- Features
- Technologies Used
- Getting Started
- API Documentation
- Authentication
- Endpoints
- Contributing
- License
LojaVirtualAPI is a robust RESTful API built with ASP.NET Core. It provides a complete solution for managing an online store. This API includes features such as JWT authentication and Swagger documentation, making it easy to integrate and use.
- Full E-commerce Management: Handle products, categories, orders, and users.
- JWT Authentication: Secure your API with token-based authentication.
- Swagger Documentation: Interactive API documentation for easy testing and exploration.
- Database Integration: Connects seamlessly with SQL Server using Entity Framework.
- Scalability: Designed to grow with your business needs.
- Backend: ASP.NET Core
- Database: SQL Server
- ORM: Entity Framework
- Authentication: JWT
- API Documentation: Swagger
- Framework: .NET
Before you begin, ensure you have the following installed:
- .NET SDK (version 6.0 or later)
- SQL Server (Express or higher)
- A code editor (Visual Studio, Visual Studio Code, etc.)
-
Clone the repository:
git clone https://github.com/sameterl/LojaVirtualAPI.git
-
Navigate to the project directory:
cd LojaVirtualAPI -
Restore the NuGet packages:
dotnet restore
-
Update the database connection string in
appsettings.json. -
Run the migrations to set up the database:
dotnet ef database update
-
Start the application:
dotnet run
Configure the application by editing the appsettings.json file. Here, you can set your database connection string, JWT secret key, and other application settings.
The API is documented using Swagger. Once the application is running, navigate to http://localhost:5000/swagger to access the interactive API documentation. This allows you to test endpoints directly from your browser.
The API uses JWT for authentication. To access protected resources, you need to obtain a token by sending a POST request to the /api/auth/login endpoint with valid user credentials.
POST /api/auth/login
{
"username": "your_username",
"password": "your_password"
}Upon successful login, the API will return a JWT token. Use this token in the Authorization header for subsequent requests.
Here are some key endpoints available in the API:
-
Get All Products
- Endpoint:
GET /api/products - Description: Retrieve a list of all products.
- Endpoint:
-
Get Product by ID
- Endpoint:
GET /api/products/{id} - Description: Retrieve a specific product by its ID.
- Endpoint:
-
Create Product
- Endpoint:
POST /api/products - Description: Add a new product to the store.
- Endpoint:
-
Get All Categories
- Endpoint:
GET /api/categories - Description: Retrieve a list of all categories.
- Endpoint:
-
Create Category
- Endpoint:
POST /api/categories - Description: Add a new category to the store.
- Endpoint:
-
Get All Orders
- Endpoint:
GET /api/orders - Description: Retrieve a list of all orders.
- Endpoint:
-
Create Order
- Endpoint:
POST /api/orders - Description: Create a new order.
- Endpoint:
Contributions are welcome! If you want to improve this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/YourFeature). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
For more information, visit the Releases section to download the latest version and execute it.