Skip to content

REST API

nestorpersist edited this page Aug 17, 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 easier 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 specify 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=s   returns database state
GET  /Database?info=c   returns database configuration
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)

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 /Database/server:Server

Ring Commands

GET /Database/ring:Ring

Node Commands

GET /Database/ring:Ring/Node
Clone this wiki locally