Skip to main content

Introduction

The DADDO API is a RESTful API that enables you to manage products, sales, categories, and user data for your inventory management system. The API uses JSON for request and response bodies and follows standard HTTP response codes.

Base URL

The API base URL is configured via environment variables:
VITE_URL2=https://api.yourdomain.com
All API endpoints are relative to this base URL.

Authentication

The DADDO API uses Bearer token authentication. Most endpoints require a valid JWT token to be included in the request header:
Authorization: Bearer YOUR_TOKEN_HERE
The token is automatically included in requests via an Axios interceptor that reads from localStorage or sessionStorage.

Authentication Guide

Learn how to obtain and use authentication tokens

Request Format

Content Types

The API accepts the following content types:
  • application/json - For most requests
  • multipart/form-data - For file uploads (e.g., product images)

Example Request

curl -X POST https://api.yourdomain.com/user/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securepassword"
  }'

Response Format

Success Response

Successful requests return a 200 or 201 status code with a JSON response:
{
  "success": true,
  "data": {
    // Response data
  }
}

Error Response

Error responses include an error message and appropriate HTTP status code:
{
  "error": "Error message",
  "message": "Detailed error description"
}

HTTP Status Codes

The API uses standard HTTP status codes:
CodeDescription
200Success - Request completed successfully
201Created - Resource created successfully
400Bad Request - Invalid request parameters
401Unauthorized - Missing or invalid authentication token
403Forbidden - Insufficient permissions
404Not Found - Resource not found
500Internal Server Error - Server error occurred

Error Handling

Token Expiration

When a token expires, the API returns a 401 status code. The frontend automatically:
  1. Detects the 401 response via response interceptor
  2. Clears stored tokens and user data
  3. Dispatches a logout action
  4. Redirects to the login page

Automatic Logout

api.interceptors.response.use(
  (response) => response,
  (error) => {
    if (error.response?.status === 401) {
      // Clear authentication data
      localStorage.removeItem("token");
      sessionStorage.removeItem("token");
      // Dispatch logout action
      store.dispatch({ type: LOGOUT });
    }
    return Promise.reject(error);
  }
);

Rate Limiting

Currently, the API does not enforce rate limiting. However, please be mindful of request volume to ensure optimal performance.

CORS

The API is configured with withCredentials: false, meaning cookies are not sent with requests. Authentication is handled via Bearer tokens in the Authorization header.

API Sections

Authentication

User registration, login, and password reset endpoints

Products

Create, read, update, and delete products and categories

Catalog

Access user catalogs with filtering options

Sales

Manage sales transactions and confirmations

Dashboard

Retrieve analytics and dashboard metrics

SDK and Libraries

The frontend uses Axios for HTTP requests with configured interceptors for authentication and error handling. You can use any HTTP client that supports Bearer token authentication.

Support

For API support or questions:
  • Check the specific endpoint documentation
  • Review error messages for troubleshooting guidance
  • Ensure your authentication token is valid and not expired

Build docs developers (and LLMs) love