Skip to main content

Introduction

The OpenCart API provides a comprehensive REST-based interface for managing your e-commerce store programmatically. It enables developers to integrate OpenCart with external systems, build custom applications, and automate store operations.

Base URL

All API requests should be made to:
https://your-store.com/index.php?route=api/

API Architecture

The OpenCart API follows a stateful session-based architecture:
  1. Session Management - API operations maintain session state
  2. Controller-Based - Each API endpoint is implemented as a controller
  3. JSON Responses - All responses are returned in JSON format
  4. Validation - Comprehensive input validation and error handling

Available API Groups

Catalog API

Manage products, categories, and manufacturers

Sales API

Handle cart, orders, customers, and checkout operations

Account API

Manage customer authentication, addresses, and wishlists

Localization API

Access currencies, countries, and zones data

API Workflow

A typical API workflow for creating an order:

Response Format

All API endpoints return JSON responses with a consistent structure:

Success Response

{
  "success": "Operation completed successfully",
  "data": {
    // Response data
  }
}

Error Response

{
  "error": {
    "warning": "General error message",
    "field_name": "Field-specific error message"
  }
}

Key Features

Add products, manage quantities, apply discounts, and calculate totals with full support for product options and subscriptions.
Complete checkout flow including customer data, addresses, shipping methods, payment methods, and order confirmation.
Retrieve product information, categories, manufacturers, and apply filters for product searches.
Handle customer authentication, profile data, addresses, and wishlists.

Validation

The API includes comprehensive validation:
  • Length Validation - Using oc_validate_length() for string fields
  • Email Validation - Using oc_validate_email() for email addresses
  • Regex Validation - Custom validation patterns for specific fields
  • Stock Validation - Automatic stock checking for products
  • Address Validation - Country and zone validation
The API is designed for server-to-server communication. All session data is stored server-side and managed through the session system.

Next Steps

Authentication

Learn how to authenticate API requests

Error Handling

Understand error codes and handling

Cart API

Start with cart operations

Orders API

Learn order management

Code Examples

View complete examples in our API guides: