# Storefront API

## Discount Ninja's storefront components

Discount Ninja includes frontend components that interact with the storefront and allow the app to:

* Discover available promotions based on the user's context
* Calculate discounts for products based on applicable promotions
* Apply those discounts to the products displayed on the storefront on the product pages (PDP), collection pages (PLP) and the cart

The key storefront component is the Price Rule Engine, documented [here](https://developers.discountninja.io/discount-ninja-developer-hub/storefront-api/promotion-engine).

## Extending and integrating

Check out our [JavaScript API](https://developers.discountninja.io/discount-ninja-developer-hub/storefront-api/promotion-engine/javascript-api) if you want to extend the capabilities of Discount Ninja's Price Rule Engine or integrate it with your theme or your app.

The functions and events provided by the JavaScript API can be used to integrate with:

* custom drawer carts
* subscription apps
* loyalty apps
* ...

## Widgets

Additionally, the app includes components that help to increase Average Order Value and increase Conversion Rate by effectively displaying promotions using widgets.

Learn more about widgets [here](https://developers.discountninja.io/discount-ninja-developer-hub/storefront-api/widgets).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.discountninja.io/discount-ninja-developer-hub/storefront-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
