Read API Documentation

This document describes the usage of the Megasense Read API, used for listing sensors and accessing their data.

Listing keys (sensors)

You need to know the project (bucket) you are interested in to list all the keys (sensors) that belong to it. You get access to one or more buckets when you apply for credentials on the landing page.


curl --header "Content-Type: application/json" -d \
  '{"accessKey": "secret, ask someone for this"}' \
  https://megasense-server.cs.helsinki.fi/read/v3/listKeys/aqdata-urbansense

Will return the following JSON:

Listing data items (sensor messages)

You need to know the sensor you are interested in, and have an idea of when the data was recorded, to access its data. the `154` in the example refers to a unix timestamp prefix, meaning between `1540000000` and `1549999999` (Saturday 20.10.2018 01:46:40 UTC and Tuesday 12.2.2019 19:33:19 UTC). You can use the unix date command to figure out what you want. Note that using just "1" will give you all data from the year 2001 until the year 2033, which should be good enough for now.

Date usage help:

$ date -u -d @1549999999

ti 12.2.2019 19.33.19 +0000

$ date -u -d @1540000000

la 20.10.2018 01.46.40 +0000

$ date -d "2019-02-13" +%s

1550008800

Usage example:


curl --header "Content-Type: application/json" -d \
  '{"accessKey": "secret, ask someone for this"}' \
  https://megasense-server.cs.helsinki.fi/read/v3/listJson/aqdata-urbansense/microsmear_smear/154

will return:


["aqdata-urbansense/microsmear_smear/1549573374833.jsonl",
 "aqdata-urbansense/microsmear_smear/1549573358475.jsonl",
 "aqdata-urbansense/microsmear_smear/1549573342130.jsonl",
 "aqdata-urbansense/microsmear_smear/1549573260769.jsonl",
 "aqdata-urbansense/microsmear_smear/1549573325816.jsonl",
 "aqdata-urbansense/microsmear_smear/1549573293425.jsonl",
 "aqdata-urbansense/microsmear_smear/1549573309461.jsonl",
 "aqdata-urbansense/microsmear_smear/1549573277121.jsonl"]

Reading an item

To read an item, you need to know its exact path. Refer to the examples above for how to list items.


curl --header "Content-Type: application/json" -d \
  '{"accessKey": "secret, ask someone for this"}' \
  https://megasense-server.cs.helsinki.fi/read/v3/download/aqdata-urbansense/microsmear_smear/1549573374833.jsonl

will return:

Reading multiple items at once (with optional filtering)

You need to know the key to read data under it. The above call can be used for that. Usage example:


curl --header "Content-Type: application/json" -d \
  '{"accessKey": "secret, ask someone for this", "from": 1549972866864, "to": 1549972890000}' \
  https://megasense-server.cs.helsinki.fi/read/v3/download/aqdata-urbansense/microsmear_smear

will return: