Introduction
Open Network for Digital Commerce (ONDC) is an open network aimed at democratizing digital commerce in India. As a Technology Service Provider (TSP), you need to understand how various APIs work to enable seamless integration for Seller Apps, Buyer Apps, and Gateways. In this guide, we’ll go through all the major APIs: search, select, init, confirm, track, cancel, update, status, and rating.

ONDC Protocol Overview

ONDC APIs are built on top of the Beckn Protocol, following an asynchronous request-response model where APIs interact via HTTP and message brokers like RabbitMQ.

API Workflow

The APIs generally follow this sequence:

  1. Search - The buyer searches for products/services.
  2. Select - The buyer selects specific products and prepares for order placement.
  3. Init - Initializing an order to confirm availability and pricing.
  4. Confirm - Finalizing the order and generating an order ID.
  5. Track - Tracking the order status.
  6. Update - Updating the order (e.g., modifying delivery time).
  7. Cancel - Canceling an order before fulfillment.
  8. Status - Checking the current status of an order.
  9. Rating - Providing feedback after order completion.

API Details

1. Search API

  • Purpose: To search for products or services provided by various sellers.
  • Request:
{
  "context": {
    "domain": "retail",
    "action": "search",
    "city": "std:080",
    "timestamp": "2025-03-13T10:00:00.000Z"
  },
  "message": {
    "intent": {
      "item": {
        "descriptor": {
          "name": "Shoes"
        }
      }
    }
  }
}
  • Response: Returns a list of matching products from various sellers.

2. Select API

  • Purpose: To select specific products from the search results.
  • Request:
{
  "context": {
    "domain": "retail",
    "action": "select",
    "timestamp": "2025-03-13T10:02:00.000Z"
  },
  "message": {
    "order": {
      "items": [
        { "id": "item1", "quantity": { "count": 1 } }
      ]
    }
  }
}
  • Response: Returns availability, price, and other details of the selected items.

3. Init API

  • Purpose: To initiate the order placement process.
  • Request:
{
  "context": {
    "domain": "retail",
    "action": "init",
    "timestamp": "2025-03-13T10:04:00.000Z"
  },
  "message": {
    "order": {
      "provider": { "id": "seller1" },
      "items": [
        { "id": "item1", "quantity": { "count": 1 } }
      ]
    }
  }
}
  • Response: Confirms the order details before finalization.

4. Confirm API

  • Purpose: To confirm the order and generate a unique order ID.
  • Request:
{
  "context": {
    "domain": "retail",
    "action": "confirm",
    "timestamp": "2025-03-13T10:06:00.000Z"
  },
  "message": {
    "order": {
      "id": "order123",
      "payment": { "type": "ON-ORDER" }
    }
  }
}
  • Response: Returns the confirmed order ID and order details.

Additional APIs

  • Track: To track order status.
  • Update: To update order details (e.g., delivery instructions).
  • Cancel: To cancel an order before fulfillment.
  • Status: To fetch the current status of an order.
  • Rating: To provide feedback and ratings post-delivery.

How These APIs Work Together

The ONDC protocol follows a request-response pattern where each API call generates a unique transaction ID. The communication between Buyer and Seller nodes is asynchronous and may involve message queues.