Public Repository

Last pushed: 2 years ago
Short Description
A simple Public Key-Value storage (alpine+erlang)
Full Description

Public KV

Command line API

UUID=`curl -s $KV/uuid`
curl -XPUT -d some-data $KV/key/$UUID/some-key
# returns ok
curl $KV/key/$UUID/some-key
# returns some-data

In browser API

Suppose you want to store something from script running in browser, and then retrieve
the value from somewhere else. This is a primitive key-value store exactly for that. Keys must not contain '/'.

Usage example (from browser):

function store(id, obj) {
        url: '' + id,
        type: 'PUT',
        data: JSON.stringify(obj),
        contentType: "application/json",
        processData: false,

store('what-ever-key', { data: "value" });


# erlang must be installed (see docker image for mandatory erlang components)


_rel/pubkv_release/bin/pubkv_release start

Run (docker version)

mkdir Mnesia
docker run -td -v $(pwd)/Mnesia:/src/pubkv/_rel/pubkv_release/Mnesia -p 10080:10080 andrey01/pubkv:latest

Live Demo


Generate UUID

UUID=`curl -s $KV/uuid`


curl -X PUT -H "Content-Type: application/json"  -d '{"key": "json data"}' $KV/key/$UUID/some-data
curl -X PUT -H "Content-Type: application/json"  -d '{"key": "other data"}' $KV/key/$UUID/some-other-data

Returns: HTTP 200, ok. Keys will be created with default TTL=24*3600 seconds (one day).

Put with TTL

curl -X PUT -d data $KV/key/$UUID/some-key?ttl=60

TTL = Time To Live in seconds. Key will be deleted after TTL will expire.

Persistent keys

curl -X PUT -d data $KV/key/$UUID/some-key?ttl=keep

Hidden keys

curl -X PUT -d data $KV/skey/$UUID/hidden-key
curl $KV/skey/$UUID/hidden-key
curl -X DELETE $KV/skey/$UUID/hidden-key

Hidden keys (skey) are stored as sha256 hashes, and are not visible
in keys list response to curl $KV/skey/$UUID.

List keys

curl $KV/key/$UUID

Returns: HTTP 200, ["some-data", "some-other-data"] or []


curl $KV/key/$UUID/some-data

Returns: HTTP 200, {"key": "json data"}

curl $KV/key/$UUID/some-missing-key

Returns: HTTP 404, not found


curl -X DELETE $KV/key/$UUID/some-data
curl -X DELETE $KV/key/$UUID

Returns: HTTP 200, ok

Readonly Aliases

Create an UUID alias only for reading (write and delete take no effect)

ALIAS=`curl -s $KV/alias/$UUID`
curl $KV/key/$ALIAS/some-data

CORS Support

Each OPTIONS request returns response with headers set:

Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: VALUE_OF(Access-Control-Request-Method)
Access-Control-Allow-Headers: VALUE_OF(Access-Control-Request-Headers)

Therefore allowing use from everywhere.

Closing words

Public beta available at:

Source code:

Docker Pull Command