Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »


1.0.7 • Public • Published


RESTful service wrapper around LevelDB

What is LAAS?

LevelDB as a service (LAAS), is a service wrapper around the LevelDB implementation provided by Google. This project is aimed at making it easy to start using LevelDB with a much lower barrier of entry. One way this project reduces the barrier to entry is by building out a RESTful API that provides access to the underlying functionality. HTTP request libraries are a dime a dozen, which makes communicating with this service much easier than needing to write native libraries to the underlying functionality.


LAAS is currently under development. While the feature set is currently limited, there is opportunity to grow the service to be much more robust.


LevelDB is an extremely powerful key-value store, but finding language specific clients for it can be difficult. Looking around at other various LSMTree based document stores, non of them offered the simplicity and ease of use that I wanted. LevelDB was by far the easiest to get running, but it posed one interesting challenge, finding client libraries to communicate with the system. Unlike MongoDB and MySQL, LevelDB doesn't stand up it's own service layer making it extremely difficult to talk to. Instead, I decided to take a supported implementation and build out a service wrapper around the underlying functionality. In conjunction with the native LevelDB library, this service wrapper offered the service layer that I was looking for.

Get Started

Before proceeding, be sure to hae NodeJS and NPM installed. Detailed instructions on how to install NodeJS and NPM can be found in the previous link.


Before getting started with LAAS, it's important to make sure that all dependencies have been installed. Outside of NodeJS and NPM, LAAS only requires two other key libraries: snappy and leveldb.


Snappy is a compression library developed by Google. Rather than trying to get the best compression, it attempts to get reasonable compression but at really high speeds.


brew install snappy


sudo apt-get install build-essential 
sudo apt-get install libsnappy-dev


LevelDB is a high performance key-value store, backed by an LSMTree.


brew install leveldb


There is currently no version of the library available in the apt-get repositories. In order to install, follow the directions as if you were installing from source.

From Source

wget https://github.com/google/leveldb/archive/v${LEVELDB_VERSION}.tar.gz
tar -xzf v${LEVELDB_VERSION}.tar.gz
sudo mv libleveldb.* /usr/local/lib
cd include
sudo cp -R leveldb /usr/local/include
sudo ldconfig


Once the dependencies have been installed, installing LAAS is simple.

npm install -g laas

Once it's installed, you need to start the laas daemon. This can be done using the start command.

laas start

When completed, this will start a web server running on *:6931. You can test this by attempting to create a database.

$ curl -X POST -d 'name=testdb' http://localhost:6931/api/v1/dbs

If you want to change the encoding type, then you can add on the corresponding body.

$ curl -X POST -d 'name=jsondb&keyEncoding=json&valueEncoding=json' http://localhost:6931/api/v1/dbs

Once created, you can insert documents into the database. There are two approaches to inserting documents into the database. The first being a single document approach. This allows clients to insert documents into the database one at a time.

$ curl -X POST -d 'key=abcdefg&value=Lorem%20ipsum%20dolor%20sit%20amet.' http://localhost:6931/api/v1/dbs/testdb/docs
[{"key":"abcdefg","value":"Lorem ipsum dolor sit amet."}]

$ curl -X POST -H 'Content-Type: application/json' -d '{"key":{"name": "abcdefg"},"value":{"text": "Lorem ipsum dolor sit amet."}}' http://localhost:6931/api/v1/dbs/jsondb/docs
[{"key":{"name":"abcdefg"},"value":{"text":"Lorem ipsum dolor sit amet."}}]

The second approach allows documents to be created in batch. This approach offers a higher write throughput and is more preferred over the single document approach.

$ curl -X POST -H 'Content-Type: application/json' -d '{"docs":[{"key":"key1","value":"value1"},{"key":"key2","value":"value2"},{"key":"key3","value":"value3"}]}' http://localhost:6931/api/v1/dbs/testdb/docs

$ curl -X POST -H 'Content-Type: application/json' -d '{"docs":[{"key":{"a":"compositeKey1","b":"compositeKey2"},"value":{"a":"compositeValue1","b":"compositeValue2"}},{"key":{"a":"compositeKey3","b":"compositeKey4"},"value":{"a":"compositeValue3","b":"compositeValue4"}},{"key":{"a":"compositeKey5","b":"compositeKey6"},"value":{"a":"compositeValue5","b":"compositeValue6"}}]}' http://localhost:6931/api/v1/dbs/jsondb/docs

Once you have documents, you can query for them as easy as a single get request. Again, this service offered two approaches to retrieving information from the database. The first allows documents to be retrieved one at a time.

$ curl http://localhost:6931/api/v1/dbs/testdb/docs/key1

The second is to be able to retrieve multiple documents at once.

$ curl 'http://localhost:6931/api/v1/dbs/testdb/docs?key=key1&key=key2'

It's as easy as that! See the documentation section for additional operations that can be performed on the service.


Documentation has been provided for both the command line utility and the api documentation.








npm i laas

DownloadsWeekly Downloads






Last publish


  • avatar