Messages

Every message is one JSON object on one line with a type. Ignore types you don't know: future versions of Nook will add more.

Your program to Nook (stdout)

typeFieldsEffect
tileviewReplaces the tile.
pageview actions?Replaces the page. Once you send a page, clicking the tile opens it. actions are round header buttons: [{id, icon, tooltip}].
badgebadgeShows something in the collapsed pill. null clears it. See below.
activeactiveLights the tile with the accent color.
open_page / close_pageOpens or closes your page, if the panel is open.
showOpens the notch, pinned, on your page. Use it for alerts.
copytextPuts text on the clipboard.
opentargetOpens a URL, file or folder with its default app.
loglevel messageWrites to Nook's log: debug, info, warn or error.

Badges

BadgeShows
{"kind": "ring", "progress": 0.4, "label": "12:00"}A progress ring and a short label, in place of the pill's clock.
{"kind": "glyph", "icon": "bell"}A small icon on the right of the pill.
{"kind": "pulse"}A pulsing dot: something arrived.

Nook to your program (stdin, live mode)

typeFieldsWhen
helloprotocol nook_version plugin_id data_dir theme{dark,accent}First, right after your program starts.
eventid kind value?A control was used. kind is click change submit commit.
tile_clickThe tile was clicked somewhere other than one of your controls.
page_open / page_closeYour page appeared or went away. Do expensive work only while it's open.
layouttarget size width heightThe space for your tile or page in points. Sent again when it changes.
themedark accentThe user changed the theme or accent color.
hotkeyYour manifest's hotkey was pressed.
filespathsFiles were dropped on your open page (needs accepts_files).
shutdownNook is quitting or reloading. Save your state now; the program is stopped 0.4 s later.

A full exchange

json
← {"type":"hello","protocol":1,"nook_version":"0.1.0","plugin_id":"counter","data_dir":"C:\\Users\\you\\AppData\\Roaming\\Nook\\plugin-data\\counter","theme":{"dark":true,"accent":"#7C5CFF"}}
→ {"type":"tile","view":{"type":"text","text":"0","size":"title"}}
← {"type":"layout","target":"tile","size":"small","width":44,"height":44}
← {"type":"event","id":"inc","kind":"click"}
→ {"type":"tile","view":{"type":"text","text":"1","size":"title"}}
→ {"type":"badge","badge":{"kind":"ring","progress":0.1,"label":"1"}}

← is stdin (from Nook), → is stdout (from your program).