Skip to content

Project 2 - API Documentation

Complete REST API reference for Project 2.

Production: https://api.project2.com/v1
Development: http://localhost:3000/v1

All API requests require authentication via JWT token:

Terminal window
Authorization: Bearer <your-token>

Login with email and password.

Request:

{
"email": "user@example.com",
"password": "SecurePassword123"
}

Response:

{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "123",
"email": "user@example.com",
"name": "John Doe"
}
}

Get user details by ID.

Response:

{
"id": "123",
"email": "user@example.com",
"name": "John Doe",
"createdAt": "2025-01-01T00:00:00Z"
}

Update user profile.

Request:

{
"name": "Jane Doe",
"bio": "Software developer"
}

List all products with pagination.

Query Parameters:

  • page (number): Page number (default: 1)
  • limit (number): Items per page (default: 20)
  • sort (string): Sort field (default: createdAt)

Response:

{
"products": [...],
"total": 100,
"page": 1,
"pages": 5
}

Create a new product (Admin only).

Request:

{
"name": "Product Name",
"description": "Product description",
"price": 99.99,
"stock": 100
}

All errors follow this format:

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid email format",
"details": {
"field": "email"
}
}
}
  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 429 - Too Many Requests
  • 500 - Internal Server Error

Official SDKs available for:

  • JavaScript/TypeScript
  • Python
  • Go
  • Ruby