JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 60
  • Score
    100M100P100Q104966F
  • License MIT

Package Exports

  • ondc-campaign-sdk
  • ondc-campaign-sdk/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ondc-campaign-sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

๐Ÿ›๏ธ ONDC Campaign SDK

npm version License: MIT Made with โค๏ธ

A lightweight & beautiful SDK to fetch and display live ONDC campaign products. Whether you're building a storefront, promotion landing page, or partner dashboard โ€” plug & play this SDK to show campaigns with style ๐Ÿš€

๐Ÿ“บ Watch How It Works

Watch the video


โœจ Features

  • ๐Ÿ“ข Campaign Info โ€” name, description, banner, and URLs
  • ๐Ÿ›’ Product Details โ€” seller, pricing, image, category, discount
  • ๐ŸŽจ Styled UI Renderer โ€” embed product cards with optional themes
  • ๐Ÿ“ฑ Mobile Responsive โ€” optimized HTML ready for any screen
  • โš™๏ธ Zero Config โ€” just install & run. That's it.

๐Ÿ“ฆ Installation

npm install ondc-campaign-sdk

โšก Quick Start

1. Fetch Campaign Products (Raw JSON)

import { fetchLiveCampaignProducts } from "ondc-campaign-sdk";

const data = await fetchLiveCampaignProducts();
console.log(data);

2. Generate Styled HTML (for embedding)

<div id="campaign-section"></div>
// @ts-ignore
import { fetchLiveCampaignProductsWithHtml } from "ondc-campaign-sdk";

async function loadLiveCampaignProducts() {
  const container = document.getElementById("campaign-section");
  if (container) {
    const html = await fetchLiveCampaignProductsWithHtml(5); // show 5 products
    container.innerHTML = html;
  } else {
    console.warn("Container #campaign-section not found.");
  }
}

// Call the function
loadLiveCampaignProducts();

With custom styles:

const styles = {
  primary: "#0d9488",
  accent: "#ef4444",
  bgLight: "#f0fdfa",
  borderRadius: "16px",
};

const html = await fetchLiveCampaignProductsWithHtml(6, styles);

๐Ÿงช API Response Format

{
    "_id": "",
    "campaignName": "",
    "description": "",
    "banner": "",
    "products": [
        {
            "productId": "",
            "additiveInfo": "",
            "locations": "",
            "brand": "",
            "commonOrGenericNameOfCommodity": "",
            "variantProducts": [],
            "parentCategory": "",
            "cancellable": "",
            "vendorName": "",
            "manufacturerName": "",
            "aiProductName": "",
            "attrTag": [
                {
                    "code": "",
                    "list": [
                        {
                            "code": "",
                            "value": ""
                        }
                    ]
                }
            ],
            "storefrontDays": [],
            "vegTag": "",
            "returnPickup": "",
            "nutritionalInfo": "",
            "deliveryTimeInShortText": "",
            "productRatings": "",
            "sellerId": "",
            "isNonVeg": "",
            "categoryName": [],
            "aiCategoryName": "",
            "unit": "",
            "galleryImages": [
                {
                    "url": "",
                    "type": ""
                }
            ],
            "hubId": "",
            "tags": [],
            "categoryId": [],
            "availableOnCod": "",
            "manufacturerAddress": "",
            "brandName": "",
            "groupAttributes": {
                "G1": {
                    "Brand": "",
                    "Colour": ""
                },
                "G3": {
                    "Gross Weight Unit of Measurement": "",
                    "Length x Breadth x Height (Cubic Cm.)": ""
                },
                "G2": {
                    "Time to Ship": ""
                },
                "G4": {
                    "Manufacturer": "",
                    "COD available (Y/N)": "",
                    "Returnable (Y/N)": ""
                },
                "g1": {
                    "Cancellable (Y/N)": ""
                }
            },
            "netQuantity": "",
            "storeName": "",
            "returnable": "",
            "discountPercentage": "",
            "winningVariant": "",
            "timeToShipUnit": "",
            "countryOfOrigin": "",
            "socialCredsTags": [],
            "discountedPrice": "",
            "ondcCategoryId": "",
            "discountEndDate": "",
            "imgUrl": "",
            "customerSupportDetails": "",
            "variantValue": "",
            "measureOfCommodityInPkg": "",
            "manufacturingDate": "",
            "monthYearOfManufacturePackingImport": "",
            "timeToShip": "",
            "customizedBlockId": "",
            "providerId": "",
            "estimatedDeliveryTime": "",
            "unitAmount": "",
            "tagsDetails": [],
            "productName": "",
            "ean": "",
            "storeImage": "",
            "regularPrice": "",
            "returnWindow": "",
            "_id": "",
            "images": []
        }
    ],
    "isActive": "",
    "createdAt": "",
    "categories": [],
    "__v": ""
}

๐ŸŽจ Style Options (Optional)

{
  primary: "#3d5af1",
  primaryDark: "#2a3eb1",
  accent: "#ff6b6b",
  text: "#333333",
  textLight: "#777777",
  bgLight: "#f8f9fa",
  white: "#ffffff",
  shadow: "0 10px 30px rgba(0,0,0,0.08)",
  borderRadius: "12px"
}

๐Ÿ“œ License

MIT License ยฉ 2025 Samhita CGF


๐Ÿค Contributing

We'd love your help to make this better!

  • ๐Ÿž Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ“ฅ Submit pull requests
  • ๐ŸŒŸ Star the repo if you find it useful!

๐Ÿ’ฌ Support

Have a question or need help?
Feel free to reach out: mja@samhita.org


๐Ÿงฉ Coming Soon

  • Filters by category or seller
  • Sorting options (price, discount)
  • Lazy loading for product lists
  • CDN-ready minified build

Enjoy building cool stuff with ONDC ๐Ÿ’™