Skip to main content
Widgets are the core building blocks in Widgetic. Each widget is a self-contained, configurable UI component that can be embedded anywhere.

Overview

With the Widgets API, you can:
  • List the widgets your account owns, one page at a time
  • Create a widget
  • Batch fetch up to 50 widgets by ID

List Widgets

GET /widgets lists the widgets your account owns, newest first. Pass page (counting from 1) and size (1 to 100, 20 when left out) to read the list one page at a time.
meta carries the figures you need to walk the list:
A page past the end is an empty list, not an error.
Without page and size, the call returns the whole list in one response. That only suits an account with a few widgets: for a large one the response can be cut short, and nothing in it says so. If you do not know how many widgets an account holds, always page.
To read every widget, keep asking for the next page until meta.hasNextPage is false:

The Widget on a Canvas

A canvas holds one widget. Pass canvasId to find the widget on one of your canvases: the list has that one widget, or none while the canvas is empty. It is always returned whole, whatever page and size say.

Widgets for One Managed User

This is for partners. Managed users exist only on a partner’s account, and working with them takes an active partner API key (see Managed Users); no other key can make a managed user or file anything under one. If you file widgets under your customers (see Managed Users), pass managedUserId (Widgetic’s id for the managed user) or managedUserExternalId (your own id for them) to list only that customer’s widgets. Send one of them, never both. It combines with page, size and canvasId, and it only narrows the list to your own account’s widgets.
A managed user that is not one of yours answers 404 with the code MANAGED_USER_NOT_FOUND. With a key that is not a partner’s, that is every managed user.
The list takes no sort parameter, and no filter other than canvasId and the managed user: it is always newest first.

Create a Widget

POST /widgets creates a widget for your account: a named record with a type and some starting content, on a canvas of its own (or on an empty canvas of yours that you name: a canvas holds one widget). It costs no credits and has no code yet; the code is generated for it afterwards. A widget is a draft until you send isDraft: false.
The response has status 201 and carries the new widget in data (shortened here):

Fields

Only the fields above are used. Anything else in the body is ignored, with one exception: managed_user_id and managed_user_external_id are refused with 400 MANAGED_USER_REFERENCE_INVALID, so that a widget meant for a customer is never created without one. The answer carries managedUserId. An update does not change it: move the widget to another customer, or take the label off, with PUT or DELETE /widgets/{id}/managed-user (the canvas the widget sits on follows it). See Managed Users for the checks Widgetic makes, and Moving Content to Another Managed User.

Where a Widget Can Go

canvasId, projectId and organizationId must name something you may use. Naming anything else is refused with 403, and the answer is the same whether the id exists or not, so it never tells you whether an id you guessed is real. A canvas holds one widget at a time, so canvasId must name a canvas that has none yet. A canvas of yours that already has a widget is refused with 409 and the code CANVAS_ALREADY_HAS_WIDGET, and nothing is created. Leave canvasId out to give the widget a canvas of its own, which is what you want unless you are filling a canvas you made empty.

Warnings

If the widget was created without all of its parts (for example, its canvas could not be told that this is its main widget), data.warnings is a list of what did not go through. It is absent when everything did. Read it before relying on the widget.

Retrying and Limits

  • The Idempotency-Key header is required (400 without it). Send the same value when you retry, so one widget is created, not two. See Idempotency.
  • Creating a widget has a limit of its own: 120 per minute for each account, counted across all of that account’s keys. Past that the API answers 429 with a Retry-After header. If you need more, ask Widgetic. See Rate Limits.

Batch Fetch Widgets

POST /widgets/batch returns up to 50 widgets by ID in one request. A widget that cannot be returned comes back in errors, with the reason, while the others still come back in widgets.

Widget Structure

A widget in an answer carries these fields: An answer can carry other fields. They are for Widgetic’s own apps and can change without notice, so read only the ones above.

Thumbnails

A widget has two thumbnails for the tiles of a list, and Widgetic makes both. A little after the last build of a widget that has none, Widgetic opens the widget in a browser of its own and saves what it shows: that is thumbnailUrl, a picture of what the widget looks like. A few minutes after the last build, Widgetic also draws thumbnailSvg, a small line drawing of the widget that stays clear in a small tile. Until then each is null, and each stays null for a widget that was never built. thumbnailUrl is a public image address: use it as the src of an img. It changes when the picture is replaced, for example when the widget is published, so read the widget again rather than keeping the address. thumbnailSvg is the drawing itself, as SVG text on a 32 by 32 canvas, drawn in currentColor, so the colour is yours. Show it as a mask, 32 pixels wide, in the middle of a tile. A widget need not have one: when it is null, show thumbnailUrl. A composition has no thumbnail of its own. It shows the thumbnail of its widget, which the composition’s widgetId names, so every composition made from one widget shows the same picture. To draw a tile for each of a customer’s widgets and compositions, see Thumbnails of Widgets and Compositions.

Widget Lifecycle

Widget Versions

Widgets keep a version history. A version is created when code is generated for the widget, and it becomes live when it is published.

Embedding Widgets

A widget is shown on a page through a composition. Create a composition on the widget, fill in its values, and put the embed code in your page:
The widget needs a published version before it can be shown. Until then the public address answers 404. See Compositions for the attributes, and Embedding widgets for the embed script.

Next Steps

Compositions

Set a widget up for one place and embed it

Canvases

Edit the widget of a canvas