Collections And Keys

KVNode organizes data into collections, each containing key-value pairs. This document covers collection management and key operations in detail.

Collection Management

Create a Collection

curl -X POST "https://api.hola.cloud/v1/collections" \
  -H "apikey: your-api-key" \
  -H "secret: your-api-secret" \
  -d '{"name": "my-collection"}'
POST /v1/collections HTTP/1.1
Host: api.hola.cloud
apikey: your-api-key
secret: your-api-secret

{"name": "my-collection"}
package main

import (
	"fmt"
	"io"
	"net/http"
	"encoding/json"
	"strings"
)

func main() {
	payload := map[string]any{"name": "my-collection"}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("POST", "https://api.hola.cloud/v1/collections", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("apikey", "your-api-key")
	req.Header.Set("secret", "your-api-secret")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$payload = ['name' => 'my-collection'];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/collections',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'apikey: your-api-key',
        'secret: your-api-secret',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

import json

headers = {
    "apikey": "your-api-key",
    "secret": "your-api-secret",
}

payload = {"name": "my-collection"}
body = json.dumps(payload)

response = requests.request(
    "POST",
    "https://api.hola.cloud/v1/collections",
    headers=headers,
    data=body
)

print(response.text)
const payload = {"name": "my-collection"};

const response = await fetch("https://api.hola.cloud/v1/collections", {
  method: "POST",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  },
  body: JSON.stringify(payload)
});

console.log(await response.text());
const payload = {"name": "my-collection"};

const response = await fetch("https://api.hola.cloud/v1/collections", {
  method: "POST",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  },
  body: JSON.stringify(payload)
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        var payload = Map.of("name", "my-collection");
        var body = new ObjectMapper().writeValueAsString(payload);

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/collections"))
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .header("apikey", "your-api-key")
            .header("secret", "your-api-secret")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Response:

1{"ok":true,"collection":"my-collection"}

Collections are created instantly. If the collection already exists, the operation is idempotent.

List Collections

curl "https://api.hola.cloud/v1/collections" \
  -H "apikey: your-api-key" \
  -H "secret: your-api-secret"
GET /v1/collections HTTP/1.1
Host: api.hola.cloud
apikey: your-api-key
secret: your-api-secret
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.hola.cloud/v1/collections", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("apikey", "your-api-key")
	req.Header.Set("secret", "your-api-secret")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/collections',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        'apikey: your-api-key',
        'secret: your-api-secret',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

headers = {
    "apikey": "your-api-key",
    "secret": "your-api-secret",
}

response = requests.request(
    "GET",
    "https://api.hola.cloud/v1/collections",
    headers=headers
)

print(response.text)
const response = await fetch("https://api.hola.cloud/v1/collections", {
  method: "GET",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

console.log(await response.text());
const response = await fetch("https://api.hola.cloud/v1/collections", {
  method: "GET",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/collections"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .header("apikey", "your-api-key")
            .header("secret", "your-api-secret")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Response:

1{"collections":["my-collection","config","sessions"]}

Delete a Collection

curl -X DELETE "https://api.hola.cloud/v1/collections/my-collection" \
  -H "apikey: your-api-key" \
  -H "secret: your-api-secret"
DELETE /v1/collections/my-collection HTTP/1.1
Host: api.hola.cloud
apikey: your-api-key
secret: your-api-secret
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("DELETE", "https://api.hola.cloud/v1/collections/my-collection", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("apikey", "your-api-key")
	req.Header.Set("secret", "your-api-secret")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/collections/my-collection',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => [
        'apikey: your-api-key',
        'secret: your-api-secret',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

headers = {
    "apikey": "your-api-key",
    "secret": "your-api-secret",
}

response = requests.request(
    "DELETE",
    "https://api.hola.cloud/v1/collections/my-collection",
    headers=headers
)

print(response.text)
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection", {
  method: "DELETE",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

console.log(await response.text());
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection", {
  method: "DELETE",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/collections/my-collection"))
            .method("DELETE", HttpRequest.BodyPublishers.noBody())
            .header("apikey", "your-api-key")
            .header("secret", "your-api-secret")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Response:

1{"ok":true,"collection":"my-collection"}

Deleting a collection removes all keys stored in it. This operation cannot be undone.

Key Operations

KVNode keys are strings that can contain any UTF-8 characters. Values must be valid JSON.

Set a Key

curl -X POST "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme" \
  -H "apikey: your-api-key" \
  -H "secret: your-api-secret" \
  -d '{"value": {"mode": "dark", "fontSize": 14}}'
POST /v1/collections/my-collection/keys/settings:theme HTTP/1.1
Host: api.hola.cloud
apikey: your-api-key
secret: your-api-secret

{"value": {"mode": "dark", "fontSize": 14}}
package main

import (
	"fmt"
	"io"
	"net/http"
	"encoding/json"
	"strings"
)

func main() {
	payload := map[string]any{"value": map[string]any{"fontSize": 14, "mode": "dark"}}
	bodyBytes, err := json.Marshal(payload)
	if err != nil {
		panic(err)
	}
	body := string(bodyBytes)

	req, err := http.NewRequest("POST", "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("apikey", "your-api-key")
	req.Header.Set("secret", "your-api-secret")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$payload = ['value' => ['fontSize' => 14, 'mode' => 'dark']];
$body = json_encode($payload);

$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_HTTPHEADER => [
        'apikey: your-api-key',
        'secret: your-api-secret',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

import json

headers = {
    "apikey": "your-api-key",
    "secret": "your-api-secret",
}

payload = {"value": {"fontSize": 14, "mode": "dark"}}
body = json.dumps(payload)

response = requests.request(
    "POST",
    "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme",
    headers=headers,
    data=body
)

print(response.text)
const payload = {"value": {"fontSize": 14, "mode": "dark"}};

const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", {
  method: "POST",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  },
  body: JSON.stringify(payload)
});

console.log(await response.text());
const payload = {"value": {"fontSize": 14, "mode": "dark"}};

const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", {
  method: "POST",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  },
  body: JSON.stringify(payload)
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import java.util.List;

public class Main {
    public static void main(String[] args) throws Exception {
        var payload = Map.of("value", Map.of("fontSize", 14, "mode", "dark"));
        var body = new ObjectMapper().writeValueAsString(payload);

        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme"))
            .method("POST", HttpRequest.BodyPublishers.ofString(body))
            .header("apikey", "your-api-key")
            .header("secret", "your-api-secret")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Response includes the sequence number and version:

1{"ok":true,"seq":3,"version":1}

Each successful write returns a monotonically increasing seq (global sequence) and version (per-key version), useful for optimistic concurrency control.

Get a Key

curl "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme" \
  -H "apikey: your-api-key" \
  -H "secret: your-api-secret"
GET /v1/collections/my-collection/keys/settings:theme HTTP/1.1
Host: api.hola.cloud
apikey: your-api-key
secret: your-api-secret
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("apikey", "your-api-key")
	req.Header.Set("secret", "your-api-secret")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        'apikey: your-api-key',
        'secret: your-api-secret',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

headers = {
    "apikey": "your-api-key",
    "secret": "your-api-secret",
}

response = requests.request(
    "GET",
    "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme",
    headers=headers
)

print(response.text)
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", {
  method: "GET",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

console.log(await response.text());
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", {
  method: "GET",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .header("apikey", "your-api-key")
            .header("secret", "your-api-secret")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Response:

1{"key":"settings:theme","value":{"mode":"dark","fontSize":14},"version":1,"updatedAt":"2025-01-01T00:00:00Z"}

Attempting to get a non-existent key returns a 404 error.

Delete a Key

curl -X DELETE "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme" \
  -H "apikey: your-api-key" \
  -H "secret: your-api-secret"
DELETE /v1/collections/my-collection/keys/settings:theme HTTP/1.1
Host: api.hola.cloud
apikey: your-api-key
secret: your-api-secret
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("DELETE", "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("apikey", "your-api-key")
	req.Header.Set("secret", "your-api-secret")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'DELETE',
    CURLOPT_HTTPHEADER => [
        'apikey: your-api-key',
        'secret: your-api-secret',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

headers = {
    "apikey": "your-api-key",
    "secret": "your-api-secret",
}

response = requests.request(
    "DELETE",
    "https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme",
    headers=headers
)

print(response.text)
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", {
  method: "DELETE",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

console.log(await response.text());
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme", {
  method: "DELETE",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/collections/my-collection/keys/settings:theme"))
            .method("DELETE", HttpRequest.BodyPublishers.noBody())
            .header("apikey", "your-api-key")
            .header("secret", "your-api-secret")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Response:

1{"ok":true,"seq":4,"version":2}

List Keys with Prefix and Limit

curl "https://api.hola.cloud/v1/collections/my-collection/keys?prefix=settings:&limit=20" \
  -H "apikey: your-api-key" \
  -H "secret: your-api-secret"
GET /v1/collections/my-collection/keys?prefix=settings:&limit=20 HTTP/1.1
Host: api.hola.cloud
apikey: your-api-key
secret: your-api-secret
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.hola.cloud/v1/collections/my-collection/keys?prefix=settings:&limit=20", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("apikey", "your-api-key")
	req.Header.Set("secret", "your-api-secret")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	responseBody, err := io.ReadAll(resp.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(responseBody))
}
<?php
$ch = curl_init();

curl_setopt_array($ch, [
    CURLOPT_URL => 'https://api.hola.cloud/v1/collections/my-collection/keys?prefix=settings:&limit=20',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        'apikey: your-api-key',
        'secret: your-api-secret',
    ],
]);

$response = curl_exec($ch);
if ($response === false) {
    throw new Exception(curl_error($ch));
}
curl_close($ch);

echo $response;
import requests

headers = {
    "apikey": "your-api-key",
    "secret": "your-api-secret",
}

response = requests.request(
    "GET",
    "https://api.hola.cloud/v1/collections/my-collection/keys?prefix=settings:&limit=20",
    headers=headers
)

print(response.text)
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys?prefix=settings:&limit=20", {
  method: "GET",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

console.log(await response.text());
const response = await fetch("https://api.hola.cloud/v1/collections/my-collection/keys?prefix=settings:&limit=20", {
  method: "GET",
  headers: {
    "apikey": "your-api-key",
    "secret": "your-api-secret"
  }
});

const text = await response.text();
console.log(text);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        var request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.hola.cloud/v1/collections/my-collection/keys?prefix=settings:&limit=20"))
            .method("GET", HttpRequest.BodyPublishers.noBody())
            .header("apikey", "your-api-key")
            .header("secret", "your-api-secret")
            .build();

        var response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

Both prefix and limit are optional query parameters:

  • prefix — filters keys that start with the given string
  • limit — caps the number of returned records (default: no limit)

Response:

1[
2  {"key":"settings:theme","value":{"mode":"dark","fontSize":14},"version":1,"updatedAt":"2025-01-01T00:00:00Z"},
3  {"key":"settings:locale","value":"en-US","version":1,"updatedAt":"2025-01-01T00:00:01Z"}
4]

Key Naming Conventions

While KVNode accepts any UTF-8 string as a key, we recommend following these conventions:

  • Use namespacing with colons: app:module:key (e.g. config:database:host)
  • Avoid special characters that may conflict with URL encoding (/, ?, #)
  • Keep keys readable — meaningful names simplify debugging
  • Be consistent — choose a naming pattern and apply it across all collections

Value Types

All values must be valid JSON. KVNode supports:

  • Objects: {"user": "alice", "role": "admin"}
  • Arrays: ["item1", "item2"]
  • Strings: "hello world"
  • Numbers: 42 or 3.14
  • Booleans: true or false
  • Null: null

The maximum value size is determined by the WAL backend configuration.

Comments

Leave a comment