JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 57
  • Score
    100M100P100Q104936F
  • 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 πŸš€


✨ 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>
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": [
    {
      "prices": {
        "regular": {
          "price": "",
          "formatted_price": ""
        },
        "final": {
          "price": "",
          "formatted_price": ""
        }
      },
      "ratings": {
        "average": "",
        "total": ""
      },
      "reviews": {
        "total": ""
      },
      "id": "",
      "sku": "",
      "name": "",
      "description": "",
      "url_key": "",
      "base_image": {
        "small_image_url": "",
        "medium_image_url": "",
        "large_image_url": "",
        "original_image_url": ""
      },
      "images": [
        {
          "small_image_url": "",
          "medium_image_url": "",
          "large_image_url": "",
          "original_image_url": ""
        }
      ],
      "is_new": "",
      "is_featured": "",
      "on_sale": "",
      "is_saleable": "",
      "is_wishlist": "",
      "min_price": "",
      "price_html": ""
    }
  ],
  "isActive": "",
  "createdAt": "",
  "__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 πŸ’™