API Reference - API Endpoints

Manage a room and its storage using the Liveblocks’s REST API endpoints. They’ll help you manage your data and extend Liveblocks’ functionality. You’ll find the API base URL below.

https://liveblocks.net/api/v1/

More API endpoints are coming

We’re always looking to improve and expand our API endpoints to help you unlock new use cases. Please contact us if you have any feedback or suggestions.

To use the API, you need to add a JWT token to the request’s authorization header:

1
2
curl https://liveblocks.net/api/v1/* \
-H "Authorization: Bearer YOUR_JWT_TOKEN"

You can get a JWT token by calling our authorization endpoint, using your secret key (accessible from the dashboard). The token will be valid for one hour.

1
2
curl https://liveblocks.io/api/authorize \
-H "Authorization: Bearer YOUR_SECRET_KEY"

Get the room storage data as a JSON using the endpoint below.

GET
https://liveblocks.net/api/v1/room/:roomId/storage
Some implementation details:
  • Each Liveblocks data structure is represented by a JSON element having two properties:
  • The root is always a LiveObject.
Example response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"liveblocksType": "LiveObject",
"data": {
"aLiveObject": {
"liveblocksType": "LiveObject",
"data": {
"a": 1
}
},
"aLiveList": {
"liveblocksType": "LiveList",
"data": ["a", "b"]
},
"aLiveMap": {
"liveblocksType": "LiveMap",
"data": {
"a": 1,
"b": 2
}
}
}
}

GET /v1/room/:roomId/storage/json is deprecated

https://liveblocks.net/api/v1/room/:roomId/storage/json should not be used anymore.

Initialize a room storage using the following endpoint. The storage of the room you’re initializing must be empty. The new storage data can be passed as a JSON in the request body.

POST
https://liveblocks.net/api/v1/room/:roomId/storage
Some implementation details:
  • The format of the request body is the same as what's returned by the get storage endpoint.
  • For each Liveblocks data structure that you want to create, you need a JSON element having two properties:
  • The root's type can only be LiveObject.
Example request body:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{
"liveblocksType": "LiveObject",
"data": {
"aLiveObject": {
"liveblocksType": "LiveObject",
"data": {
"a": 1
}
},
"aLiveList": {
"liveblocksType": "LiveList",
"data": ["a", "b"]
},
"aLiveMap": {
"liveblocksType": "LiveMap",
"data": {
"a": 1,
"b": 2
}
}
}
}

POST /v1/room/:roomId/storage/json is deprecated

https://liveblocks.net/api/v1/room/:roomId/storage/json should not be used anymore.

Delete all elements of the room storage using the following endpoint.

DELETE
https://liveblocks.net/api/v1/room/:roomId/storage