HTTP API

Url format

The url consists of four main parts:

http(s):// host / app / collection / key

Part Name Description
1 host The address of the server (host:port)
2 app Name of an application chosen by the user
3 collection Name of a collection chosen by the user
4 key Key in the collection. Values are accessed via keys

Store data

curl http://host/met/sensors/s1 -X POST -d '{temp: 20, city: "NY"}'

Lookup data

Data lookup is performed via the Http GET method:

curl http://host/met/sensors/s1

Update data

PUT method will update individual fields:

curl http://host/met/sensors/s1 -X PUT -d '{temp: 21}'

Continuos updates

You can keep the http connection open for sending multiple updates:

curl http://host/met/sensors/a -X PUT -T -

and then add the updates one by one in each new line:

{temp: 20}
{temp: 22}   

Delete

To delete a single value from a collection run:

curl http://host/met/sensors/s1 -X DELETE 

And to delete the whole collection run:

curl http://host/met/sensors -X DELETE 

Deleting a collection also delets history for that collection.

Query

curl http://host/met -X POST -d 'stream("sensors")
    .filter( (sensor) -> sensor.temp > 0 )'

Historical Query

curl http://host/met -X POST -d 'history("sensors", "temp")
     .filter( Time.past(1, "hour") )'

Bulk inserts

Storing multiple items at the same time is faster than storing them one by one. Post data to the collection's url with all keys and values in one JSON object:

curl http://host/met/sensors -X POST -d '{s1: {temp: 20}, 
                                          s2: {temp: 25} }'

Bulk updates work the same way:

curl http://host/met/sensors -X PUT -d '{s1: {temp: 20}, 
                                         s2: {temp: 25} }'