API Reference - Widgets
Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108056
← Back to API Reference | Getting Started
Widgets
Widgets are reusable HTML/CSS/JS components that power the front-end of your Brilliant Directories website. They can be created, modified, and rendered via the API.
data_widgets — DB table: data_widgetsThe Widget Object
| Field | Type | Description |
|---|---|---|
widget_id | integer | Unique widget ID (primary key, read-only) |
widget_name | string | Widget name/label required on create |
widget_type | string | Widget type (default: Widget) |
widget_data | text | Widget HTML content |
widget_style | text | Widget CSS styles |
widget_javascript | text | Widget JavaScript code |
widget_settings | text | Widget configuration settings (JSON or serialized) |
widget_values | text | Widget variable values |
widget_class | string | CSS class names to apply to the widget container |
widget_viewport | string | Where widget appears: front, admin, or both |
widget_html_element | string | HTML element type wrapping the widget (default: div) |
div_id | string | HTML ID attribute for the widget container |
short_code | string | Shortcode reference for this widget |
bootstrap_enabled | integer | 1 if Bootstrap framework is loaded for this widget |
ssl_enabled | integer | 1 if SSL/HTTPS is enabled for this widget |
mobile_enabled | integer | 1 if mobile viewport is enabled |
file_type | string | File type of the widget |
date_updated | string | Date widget was last updated |
updated_by | string | User who last updated this widget |
revision_timestamp | timestamp | Last modified timestamp (auto-updated) |
customize | string | Virtual field for widget customization context |
fromcron | string | Virtual field indicating cron execution context |
List Widgets
curl -X GET "https://www.yourdomain.com/api/v2/data_widgets/get?limit=25" \ -H "X-Api-Key: your-api-key-here"
Retrieve a Widget
curl -X GET "https://www.yourdomain.com/api/v2/data_widgets/get/500" \ -H "X-Api-Key: your-api-key-here"
Create a Widget
curl -X POST "https://www.yourdomain.com/api/v2/data_widgets/create" \ -H "X-Api-Key: your-api-key-here" \ -d "widget_name=My+Custom+Banner" \ -d "widget_data=%3Ch2%3EWelcome%21%3C%2Fh2%3E" \ -d "widget_viewport=front" \ -d "bootstrap_enabled=1"
Update a Widget
curl -X PUT "https://www.yourdomain.com/api/v2/data_widgets/update" \ -H "X-Api-Key: your-api-key-here" \ -d "widget_id=500" \ -d "widget_name=Updated+Banner" \ -d "widget_data=%3Ch2%3ENew+Content%21%3C%2Fh2%3E"
Delete a Widget
curl -X DELETE "https://www.yourdomain.com/api/v2/data_widgets/delete" \ -H "X-Api-Key: your-api-key-here" \ -d "widget_id=500"
Render a Widget
Returns the rendered HTML output of a widget, with all template variables processed. Useful for previewing widget output or embedding rendered content in external applications.
Example Request
curl -X POST "https://www.yourdomain.com/api/v2/data_widgets/render" \ -H "X-Api-Key: your-api-key-here" \ -d "widget_id=500"
Example Response
{
"status": "success",
"message": "Widget rendered successfully",
"name": "My Widget Name",
"output": "<h2>Welcome!</h2>"
}