> For the complete documentation index, see [llms.txt](https://apidocs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.akinon.com/commerce/widgets.md).

# Widgets

Widgets are dynamic UI components based on schemas, encompassing elements like sliders and banners that are deployable within the storefront. These elements can also store information regarding product collections and can be used for displaying products on the storefront. Widgets are formally defined within Omnitron and can be retrieved by querying them using their unique widget slug identifier.

### Model

#### Widget

| field                         | type          | description                                     |
| ----------------------------- | ------------- | ----------------------------------------------- |
| name                          | CharField     | The name of the widget.                         |
| slug                          | SlugField     | A unique slug for identifying the widget.       |
| template                      | SlugField     | The template used for rendering the widget.     |
| widget\_type                  | WidgetType    | The widget type that holds the widget's schema. |
| created\_date                 | DateTimeField | The date when the widget was created.           |
| modified\_date                | DateTimeField | The date when the widget was last modified.     |
| attributes                    | JSONField     | Attributes of the widget.                       |
| attributes\_kwargs            | JSONField     | Information about the widget's attributes.      |
| content\_type                 | ContentType   | The content type of the widget.                 |
| localized\_attributes         | JSONField     | Localized attributes specific to the widget.    |
| localized\_attributes\_kwargs | JSONField     | Information about localized attributes.         |

#### ProductCollectionWidget

| field                         | type                 | description                                              |
| ----------------------------- | -------------------- | -------------------------------------------------------- |
| name                          | CharField            | The name of the widget.                                  |
| slug                          | SlugField            | A unique slug for identifying the widget.                |
| template                      | SlugField            | The template used for rendering the widget.              |
| product\_collection           | ProductCollection    | The product collection linked to the widget.             |
| product\_limit                | PositiveIntegerField | The maximum number of products to display in the widget. |
| widget\_type                  | WidgetType           | The widget type that holds the widget's schema.          |
| created\_date                 | DateTimeField        | The date when the widget was created.                    |
| modified\_date                | DateTimeField        | The date when the widget was last modified.              |
| attributes                    | JSONField            | Attributes of the widget.                                |
| attributes\_kwargs            | JSONField            | Information about the widget's attributes.               |
| content\_type                 | ContentType          | The content type of the widget.                          |
| localized\_attributes         | JSONField            | Localized attributes specific to the widget.             |
| localized\_attributes\_kwargs | JSONField            | Information about localized attributes.                  |

### Endpoints

#### `GET` Retrieve a Widget Info

This method is used to get widget information that have been defined in Omnitron.

**Path:** `https://{commerce_url}/widgets/<widget-slug>/`

**Example Response**

Here's an example response of a product collection widget:

```json
{
  "name": "Campaign",
  "slug": "x-campaign",
  "attributes": {
    "abc": "xyz"
  },
  "template": "widgets/campaign.html",
  "products": [
    {
      "pk": 10,
      "sku": "12612662136",
      ...
    },
    {
      "pk": 11,
      "sku": "12612662137",
      ...
    },
    ....
  ]
}
```

Here's an example response of a simple widget:

```json
{
  "attributes": {
    "sliders": [
      {
        "value": {
          "name": "Kampanya",
          "slug": "kampanya"
        },
        "kwargs": null
      },
      {
        "value": {
          "name": "\u0130ndirim",
          "slug": "indirim"
        },
        "kwargs": null
      }
    ],
    "slider_items": [
      {
        "value": {
          "url": "#",
          "slider_slug": "kampanya",
          "alt": "resim",
          "image": "assets/img/slider.jpg",
          "title": "baslik"
        },
        "kwargs": null
      },
      {
        "value": {
          "url": "#",
          "slider_slug": "indirim",
          "alt": "resim",
          "image": "assets/img/slider2.jpg",
          "title": "baslik"
        },
        "kwargs": null
      },
      {
        "value": {
          "url": "#",
          "slider_slug": "kampanya",
          "alt": "resim",
          "image": "assets/img/slider2.jpg",
          "title": "baslik"
        },
        "kwargs": null
      },
      {
        "value": {
          "url": "#",
          "slider_slug": "indirim",
          "alt": "resim",
          "image": "assets/img/slider.jpg",
          "title": "baslik"
        },
        "kwargs": null
      }
    ]
  },
  "name": "Slider",
  "template": "index/slider.html",
  "slug": "slider"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.akinon.com/commerce/widgets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
