# AnimStream Widget SDK

A widget package is a UTF-8 JSON file named `widget.json`. The schema defines the
accepted keys and bounds. Requests are up to 256 KiB. Hosted previews and Studio use
the same rendering code. Version 1 uses built-in layouts, text, colours and
Studio event data. Version 1 is declarative. For original motion graphics, see [Canvas SDK v2](https://animstream.com/widget-sdk/agent-kit/CANVAS.md). Its render function runs in an isolated worker with local graphics and Studio event data.

## Alert

Set `mode: "alert"` with a 1–30 second duration. In the Flow Wizard, choose a
trigger, such as a specific gift, and your widget from the Store assets that you
own. Assign it to an animation surface and preview the flow. Studio handles the
queue, trigger matching and playback. The widget reports completion at its
configured duration. When used in a flow the event is available as
`{user}`, `{gift}`, `{count}`, `{coins}` and `{level}` in headline and detail.
Treat absent values as optional.

Both declarative and Canvas alerts can declare which Studio events reviewers
should try. For example, add `"events": ["GIFT", "FOLLOW"]` to an alert package.
Supported codes are `GIFT`, `LIKE`, `FOLLOW`, `SHARE`, `COMMENT`, `JOIN`,
`SUBSCRIBE` and `LEVEL_UP`. List each intended event once. The review simulator
offers a test button for each one. This list is optional. Streamers choose the
actual trigger in their Studio Flow. The available event fields stay the same.

## Live

Set `mode: "live"` and choose one session metric from the schema. Place it as a
source in Studio. The metric follows the active session counters. The source
settings support custom text and goal. The goal affects the optional progress
bar. The same package can be reused across scenes.

## Preview

Post the manifest JSON to `/api/widget-sdk/preview` for a watermarked test
document. The docs at animstream.com/developers/widgets provide a file picker
and an editor. Flow previews use synthetic gifts and live previews show a
sample counter. For production, Studio supplies session and flow values.

## Publishing

Open [Vendor Studio → Widgets](https://animstream.com/vendor/widgets) and load
your `widget.json`. Test the preview, choose the price in EUR and submit the
package for widget review. Check [Submissions](https://animstream.com/vendor/widgets#submissions)
for its status and any reviewer feedback. Set zero for a free listing. Connect your payout account for Store listings. AnimStream's marketplace
collects 15% of vendor sales. Set
`shareInCommunity: true` to include the approved listing in the Studio
Community widget catalog. A paid listing keeps its Store entitlement when
featured in the Community.
