Widget API
Widgets are configurable UI components that can be placed on storefront pages through the admin panel.
Endpoints
Create a Widget
Creates a new widget instance with type, area placement, and settings.
Request Schema (application/json)
| Field Name | Field Type | Required |
|---|---|---|
| type | string | No |
| name | string | No |
| status | string or integer (0, 1, '0', '1') | No |
| area | array of string | No |
| route | array of string | No |
| sort_order | string or integer | No |
| settings | object | No |
POST/api/widgets
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/widgets
fetch('https://<your domain>/api/widgets', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"widget_id": 5,
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "collection_products",
"name": "Featured Products",
"status": 1,
"setting": {
"collection": "summer-sale",
"count": 4
},
"sort_order": 10
}
}
Update a Widget
Updates an existing widget's settings, placement, or status.
Request Schema (application/json)
| Field Name | Field Type | Required |
|---|---|---|
| name | string | No |
| status | string or integer (0, 1, '0', '1') | No |
| area | array of string | No |
| route | array of string | No |
| sort_order | string or integer | No |
| settings | object | No |
PATCH/api/widgets/{id}
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/widgets/{id}
fetch('https://<your domain>/api/widgets/{id}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"widget_id": 5,
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "Featured Products Updated",
"status": 1
}
}
Delete a Widget
Permanently removes a widget instance.
Request Schema (application/json)
No request body requiredDELETE/api/widgets/{id}
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/widgets/{id}
fetch('https://<your domain>/api/widgets/{id}', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"widget_id": 5,
"uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
}