Skip to content

REST API

nestorpersist edited this page Dec 23, 2012 · 32 revisions

The OStore REST API has several uses.

  • It provides an API for clients not written in Scala.
  • It can be useful for debugging using tools such as curl.
  • The HTTP protocol makes it easy to go across firewalls and other network blocks.

OStore Keys can appear in REST urls. Here are some examples of REST key encoding.

REST               JSON  
23                 23
abc                "abc"  
"abc"              "abc" 
(23,abc)           [23,"abc"]
foo%20bar          "foo bar" 
(23,"23")          [23,"23"]
(false,"false")    [false,"false"]

Scala API options are available in the REST API using the query string. See the Scala API ScalaDoc for for additional options.

REST               Scala
reverse&ring=r1    {"reverse":true,"ring:"r1"}

REST request and responses are all JSON. Responses are by default compact encoded, but by specifying the pretty option a more human readable form is returned.

Top Level Commands

GET /         returns a list of all database names

Database Commands

GET  /Database               returns a list of all table names
GET  /Database?rings         returns a list of all ring names
GET  /Database?servers       returns a list of all server names
GET  /Database?info&get=cs   returns database info
POST /Database   

For POST the following request bodies are supported.

{"cmd":"create","config":c}
{"cmd":"delete"}
{"cmd":"start"}
{"cmd":"stop"}
{"cmd":"addTables","config":c}
{"cmd":"deleteTables","config":c}
{"cmd":"addNodes","config":c}
{"cmd":"deleteNodes","config":c}
{"cmd":"addRings","config":c}
{"cmd":"deleteRings","config":c}

Table Commands

GET /Database/Table               returns a list of keys (at most 30)
GET /Database/Table?count=N       returns a list of keys (at most N)
GET /Database/Table?info&get=rftp returns table info

Check out the Scala API ScalaDoc for more options on getting key lists. Note that there are options that permit keys of large tables to be fetched in incrementally.

Item Commands

GET    /Database/Table/Key   returns the value of the item
PUT    /Database/Table/Key   updates the value of the item
DELETE /Database/Table/Key   deletes the item
POST   /Database/Table/Key

For POST the following forms of request are supported.

{"cmd":"put","v":v,"c":c}    for opt cc (c must not have changed)
{"cmd":"delete", "c":c}      for opt cc (c must not have changed)

Server Commands

GET /server:Server?info&get=hpd  returns server info

Ring Commands

GET /Database/ring:Ring                returns list of all node names
GET /Database/ring:Ring?info&get=s     returns ring info

Node Commands

GET /Database/ring:Ring/Node?info&get=hpbf    returns node info 
Clone this wiki locally