Get started with the E-Commerce API
This guide will walk you through making your first API call to the E-Commerce API. You’ll register a new user account and receive a JWT token that you can use to access protected endpoints.Set up your environment
Ensure you have the API running locally or have access to a deployed instance. The default base URL is:
You’ll need an API key to make requests. Check your
.env file for the API_KEY value, or contact your API administrator.Register a new user
Create a new user account by sending a POST request to the
/register endpoint. This endpoint requires three fields: name, email, and password.Receive your JWT token
If registration is successful, you’ll receive a response with a JWT token that expires in 8 hours:If the email is already registered, you’ll receive an error:
Make an authenticated request
Now that you have a JWT token, you can access protected endpoints. Let’s retrieve your user profile:Expected response:
Protected endpoints require both the
x-api-key header AND the Authorization header with your JWT token.What’s next?
Now that you’ve made your first API calls, explore more features:Authentication guide
Learn more about API keys, JWT tokens, and security best practices
API reference
Explore all available endpoints including cart, orders, and reviews
Common errors
403 - Invalid API Key
403 - Invalid API Key
This error occurs when the
x-api-key header is missing or incorrect.Solution: Ensure you’re sending the correct API key in the x-api-key header with every request.401 - Access Denied
401 - Access Denied
This error occurs when accessing protected endpoints without a valid JWT token.Solution: Include your JWT token in the
Authorization header as Bearer <token>.400 - All fields are required
400 - All fields are required
This error occurs when required fields are missing from your request body.Solution: Check the endpoint documentation and ensure all required fields are included in your request.
409 - Email is already registered
409 - Email is already registered
This error occurs when trying to register with an email that already exists.Solution: Use the
/login endpoint instead, or register with a different email address.