Room

Room: a realtime room's server side. Publish to the pages in it, see who's there, ask them, and mint a token for a page to join (the TypeScript SDK's Room.join).

Rooms are named by what they're about: workflow:{id} (everyone who may open the workflow) and owner (your own open tabs, as a signed-in person). Publishing and asking need edit access to a workflow's room; an event you publish names you (from), where NoClick's own events name nobody.

noclick.Room(name, *, client=None)

A room by its name (workflow:{id}, owner). Nothing is read until you call a method.

Parameters
namestrrequired
clientClient | None

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

(default None)
Usage
room = noclick.Room(f"workflow:{workflow_id}")
print([m.user["name"] for m in room.members() if m.user])
Attributes
namestr

membersasync

room.members() -> list[RoomMember]

Who is in the room now, each as the room shows them.

Returns
list[RoomMember]

Every member: the pages in the room, and the members NoClick holds (server).

Usage
for member in noclick.Room(f"workflow:{workflow_id}").members():
    print(member.user and member.user["name"], member.data.get("selection"))

historyasync

room.history(*, since=None) -> dict[str, Any]

The room's recent events (at most its last 500 of the last ten minutes), after since when it names one still kept.

Parameters
sincestr | Nonedefault None
Returns
dict[str, Any]

{"events": [RoomEvent, ...], "reset": bool}; reset True when since was too old, so read what you show again.

Usage
found = noclick.Room(f"workflow:{workflow_id}").history(since=last_id)
for event in found["events"]:
    print(event.event, event.data)

publishasync

room.publish(event, data=None) -> str

Publishes event (lower case: letters, digits, _ . : -) with data (at most 64 KB as JSON) to everyone in the room, named as from you.

Parameters
eventstrrequired
dataAnydefault None
Returns
str

The event's id in the room.

Usage
noclick.Room(f"workflow:{workflow_id}").publish("review.ready", {"step": "draft"})

askasync

room.ask(name, args=None, *, timeout=10.0, collect_ms=0) -> dict[str, Any]

Asks the room's pages that answer name (the TypeScript SDK's room.answer) and waits for an answer, at most timeout seconds (25 at most). With collect_ms, waits that long after the first answer for the others'.

Parameters
namestrrequired
argsdict[str, Any] | Nonedefault None
timeoutfloatdefault 10.0
collect_msintdefault 0
Returns
dict[str, Any]

{"answer": {...}} (or {"answers": [...]} collecting), each naming the member that gave it, or {"error": "no_viewer" | "timeout"}.

Usage
reply = noclick.Room(f"workflow:{workflow_id}").ask("canvas.get_selected", timeout=5)

tokenasync

room.token(*, origin=None) -> RoomToken

A single-use token for a page to join the room with (Room.join(name, {token}) in TypeScript): pass url and token on as they are. origin is the page's (location.origin); the socket must come from it.

Parameters
originstr | Nonedefault None
Returns
RoomToken

The token, the socket's url (carrying its ticket) and what it lets the page do (access).

Usage
token = noclick.Room(f"workflow:{workflow_id}").token(origin="https://app.example.com")
return {"url": token.url, "token": token.token}

RoomEvent

class RoomEvent

What was published in a room: its id (what history(since=) reads after), its name, its data, and who published it (from_; None for NoClick's own).

Attributes
idstr
eventstr
dataAny
from_dict[str, Any] | None
rawdict[str, Any]

The response JSON exactly as the API sent it.

RoomMember

class RoomMember

One member of a room: a page (user who they are, color the room gave them, data what they say of themselves) or one NoClick holds (server: an agent's sandbox at work, user None).

Attributes
idstr
userdict[str, Any] | None
colorstr | None
datadict[str, Any]
serverbool
joined_atdatetime | None
rawdict[str, Any]

The response JSON exactly as the API sent it.

RoomToken

class RoomToken

A single-use token for a room's socket: hand url and token to the page that joins, within a minute.

Attributes
urlstr
tokenstr
accessstr
expires_atdatetime | None
connection_ends_atdatetime | None
rawdict[str, Any]

The response JSON exactly as the API sent it.