Liveblocks icon

Liveblocks

Call the Liveblocks REST API (rooms, comments, feeds, Yjs, AI, and more)

Yjs → Get Document (JSON)

AI-generated

Summary

Retrieve a Yjs document from a specified Liveblocks room in JSON format, optionally filtered by a key and Yjs type, and with optional inclusion of YText formatting.

Inputs

  • Room ID (required) — The identifier of the Liveblocks room from which to retrieve the Yjs document.
  • Formatting — Whether to include YText formatting in the returned document (boolean). Defaults to false.
  • Key — An optional key to return only its corresponding value from the document.
  • Yjs Type Override — Overrides the inferred Yjs type associated with the Key. Options are Y.Array, Y.Map, Y.Text, Y.XmlFragment, Y.XmlText. Defaults to Y.Map.

Output shape

A JSON object representing the Yjs document content for the specified room. If a Key is provided, the output is the value for that key optionally constrained by the Yjs Type Override. Includes YText formatting if requested.

The output document structure is derived from the Liveblocks API's getYjsDocument response. Errors can optionally include detailed request information if enabled via 'Include Request in Error' option.

Examples

Example 1: Retrieve the entire Yjs document as JSON for a Liveblocks room

Specify the Room ID, leave Key and Formatting empty or default.

Example 2: Retrieve the value for a specific key as a JSON object

Specify Room ID and Key; optionally set Yjs Type Override if the type of value differs from the default Y.Map.

Example 3: Retrieve Yjs document including YText formatting

Specify Room ID and set Formatting option to true.

Links

Discussion