Appearance
Bulk read records
POST /v4/storage/{storage}/read
Read one or more records from a namespace. The path parameter storage specifies which namespace to read from.
Request body
| Field | Type | Description |
|---|---|---|
| keys | array<string> | Optional. List of keys to read. If omitted, the response contains only latest transaction id, no keys will be returned. |
| tx | integer<int64> | Optional. Transaction ID to read from. If omitted, reads from the latest transaction. |
Response schema
| Field | Type | Description |
|---|---|---|
| data | array<Record> | Array of records that were found. |
| count | integer<int64> | Number of records returned. |
| tx | integer<int64> | Transaction ID of the read operation. |
| duration | string | Time taken to process the read request, returned in a human-readable format (e.g., "1.234567ms"). |
Record object
| Field | Type | Description |
|---|---|---|
| key | string | The key that was read |
| value | any | The value associated with the key. Will be null if key has no value. |
| tx | integer<int64> | Transaction ID when this record was last modified |
| binary | boolean | Whether the value is binary data |
Example
sh
curl --location 'https://api.litebase.io/v4/storage/sample/read' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $LITEBASE_API_KEY" \
--data '{
"keys": ["city:1", "city:2"]
}'Response:
json
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": [
{
"key": "city:1",
"value": {
"name": "Braavos"
},
"tx": 1,
"binary": false
},
{
"key": "city:2",
"value": {
"name": "Oldtown"
},
"tx": 1,
"binary": false
}
],
"count": 2,
"tx": 1,
"duration": "1.234567ms"
}Read from specific transaction
sh
curl --location 'https://api.litebase.io/sample/storage/read' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $LITEBASE_API_KEY" \
--data '{
"keys": ["city:1"],
"tx": 1
}'Response:
json
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": [
{
"key": "city:1",
"value": {
"name": "Braavos"
},
"tx": 1
}
],
"tx": 1,
"duration": "0.987654ms"
}Read when key having value cleared
Reading a key with value cleared will return key and transaction id only.
sh
curl --location 'https://api.litebase.io/sample/storage/read' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $LITEBASE_API_KEY" \
--data '{
"keys": ["city:1"]
}'Response:
json
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": [
{
"key": "city:1",
"tx": 2
}
],
"tx": 2,
"duration": "0.987654ms"
}