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.

Model name in URL: data_widgets — DB table: data_widgets

The Widget Object

FieldTypeDescription
widget_idintegerUnique widget ID (primary key, read-only)
widget_namestringWidget name/label required on create
widget_typestringWidget type (default: Widget)
widget_datatextWidget HTML content
widget_styletextWidget CSS styles
widget_javascripttextWidget JavaScript code
widget_settingstextWidget configuration settings (JSON or serialized)
widget_valuestextWidget variable values
widget_classstringCSS class names to apply to the widget container
widget_viewportstringWhere widget appears: front, admin, or both
widget_html_elementstringHTML element type wrapping the widget (default: div)
div_idstringHTML ID attribute for the widget container
short_codestringShortcode reference for this widget
bootstrap_enabledinteger1 if Bootstrap framework is loaded for this widget
ssl_enabledinteger1 if SSL/HTTPS is enabled for this widget
mobile_enabledinteger1 if mobile viewport is enabled
file_typestringFile type of the widget
date_updatedstringDate widget was last updated
updated_bystringUser who last updated this widget
revision_timestamptimestampLast modified timestamp (auto-updated)
customizestringVirtual field for widget customization context
fromcronstringVirtual field indicating cron execution context

List Widgets

GET /api/v2/data_widgets/get
Copy
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

GET /api/v2/data_widgets/get/{widget_id}
Copy
curl -X GET "https://www.yourdomain.com/api/v2/data_widgets/get/500" \
  -H "X-Api-Key: your-api-key-here"

Create a Widget

POST /api/v2/data_widgets/create
Copy
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

PUT /api/v2/data_widgets/update
Copy
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

DELETE /api/v2/data_widgets/delete
Copy
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

POST /api/v2/data_widgets/render

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

Copy
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

Copy
{
  "status": "success",
  "message": "Widget rendered successfully",
  "name": "My Widget Name",
  "output": "<h2>Welcome!</h2>"
}