Skip to content
Javascript clients for Riak.
Pull request Compare This branch is 5 commits ahead of PharkMillups:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



riak-javascript-http-client is a Javascript client for Riak, using the HTTP interface

Quick Start

Basic usage is described in this document. For more detail about each function, please see the comment docs in riak.js. You may also find the test code (in the tests/ directory) instructive.

Documentation for use of Riak clients in general can be found at

To use riak-javascript-client, start by including riak.js, json2.js, and a recent version of jQuery in your application. Next, create a client pointed at your cluster:

var baseUrl = "http://localhost:8098/riak";
var mapredUrl = "http://localhost:8098/mapred";
var client = new RiakClient(baseUrl, mapredUrl);

If you do not specify a base URL or MapReduce URL, RiakClient will supply defaults of /riak and /mapred, respectively (the library assumes that your code is running in a browser, and the host for the page is the Riak node you want to connect to).

To create an object with the key foo in the bar bucket, first ask the client for a RiakBucket object, then ask the bucket for a RiakObject. The riak-javascript-client uses a callback interface, so code looks like so:

var bucketName = "bar";
var key = "foo";
var value = {'baz':true};
   function(bucket) {
         function(status, object) {
            object.contentType = 'application/json'
            object.body = value;

Requesting an existing object looks similar, though bucket.get can be used instead of bucket.get_or_new.

Unit Tests

The riak-javascript-client includes a unit test suite that you may run against your Riak cluster. The only prerequisites are Riak, a web browser, and curl.

  1. If your Riak server is not listening on the default IP/port (, you’ll need to edit tests/setup to point to the right host and port. The variables to edit are called, helpfully, HOST and PORT.
  2. To install the test environment, run the setup script in the tests directory with the -i option:
    cd tests;./setup -i
  3. You can now run the unit tests by pointing your browser to the unit test page. Assuming Riak is listening on, the URL for the unit tests is:
  4. You can clean out any transient test data by running the setup script with the -c option:
    cd tests;./setup -c
  5. Finally, you can remove the test environment by running setup again with the -u option:
    cd tests;./setup -u


We encourage contributions to riak-javascript-client from the community.

  1. Fork the riak-javascript-client repository on Github.
  2. Clone your fork or add the remote if you already have a clone of the repository.
git clone
# or
git remote add mine
  1. Create a topic branch for your change.
git checkout -b some-topic-branch
  1. Make your change and commit. Use a clear and descriptive commit message, spanning multiple lines if detailed explanation is needed.
  2. Push to your fork of the repository and then send a pull-request through Github.
git push mine some-topic-branch
  1. A Basho engineer or community maintainer will review your patch and merge it into the main repository or send you feedback.
Something went wrong with that request. Please try again.