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.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
None)room = noclick.Room(f"workflow:{workflow_id}")
print([m.user["name"] for m in room.members() if m.user])| name | str |
membersasync
room.members() -> list[RoomMember]Who is in the room now, each as the room shows them.
Every member: the pages in the room, and the members NoClick holds (server).
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.
None{"events": [RoomEvent, ...], "reset": bool}; reset True when since was too old, so read what
you show again.
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) -> strPublishes event (lower case: letters, digits, _ . : -) with data (at most 64 KB as JSON) to
everyone in the room, named as from you.
NoneThe event's id in the room.
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'.
None10.00{"answer": {...}} (or {"answers": [...]} collecting), each naming the member that gave it, or
{"error": "no_viewer" | "timeout"}.
reply = noclick.Room(f"workflow:{workflow_id}").ask("canvas.get_selected", timeout=5)tokenasync
room.token(*, origin=None) -> RoomTokenA 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.
NoneThe token, the socket's url (carrying its ticket) and what it lets the page do (access).
token = noclick.Room(f"workflow:{workflow_id}").token(origin="https://app.example.com")
return {"url": token.url, "token": token.token}RoomEvent
class RoomEventWhat 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).
| id | str | |
| event | str | |
| data | Any | |
| from_ | dict[str, Any] | None | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
RoomMember
class RoomMemberOne 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).
| id | str | |
| user | dict[str, Any] | None | |
| color | str | None | |
| data | dict[str, Any] | |
| server | bool | |
| joined_at | datetime | None | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |
RoomToken
class RoomTokenA single-use token for a room's socket: hand url and token to the page that joins, within a minute.
| url | str | |
| token | str | |
| access | str | |
| expires_at | datetime | None | |
| connection_ends_at | datetime | None | |
| raw | dict[str, Any] | The response JSON exactly as the API sent it. |