Write Data

Overview

  • This set of api endpoints allows data to be writen to the database.

    All data is written using the REST interface. Datapoints are represented by a dictionary containing a t for the timestamp and a v for the value. TempoDB supports two types for the value: integers and floats.

    There are two main methods for writing data. Several datapoints can be written for a single series in one call. Or, several datapoints for different series at the same timestamp can be written. Single series writes are achieved by referencing the series by id or key.

  • Upserts

    Writing to a series referenced by key will cause that series to be created if the key doesn't exist. This is sort of like the upsert feature of other databases.

  • Operations

    The following write-related operations are supported:

    • Write Data by ID
    • Write Data by Key
    • Bulk Write Multiple Series

Write Data by ID

  • Description

    Writes data to a series referenced by ID.

  • Resource URL

    POST /series/id/{id}/data/
  • URL Parameters

    • id

      Specifies the id of the series to write data.

      Example Values: 01868c1a2aaf416ea6cd8edd65e7a4b8

  • Querystring parameters

    None

  • Request Body

    An array of dictionaries representing a datapoint. You can add as many timestamp/value pairs for the series at a time as you’d like.

  • Response

    A 200 OK if the request completes.

  • Side Effects

    New timestamp/value pairs are written for the given series id.

  • Example Request

    post/series/id/01868c1a2aaf416ea6cd8edd65e7a4b8/data/post data
    1. [
    2. {"t":"2012-01-08T00:21:54.000+0000","v":4.164},
    3. {"t":"2012-01-08T00:21:55.000+0000","v":3.121},
    4. {"t":"2012-01-08T00:21:56.000+0000","v":3.629}
    5. ]

Write Data by Key

  • Description

    Writes data to a series referenced by key. A new series is created with the provided key if it doesn't already exist.

  • Resource URL

    POST /series/key/{key}/data/
  • URL Parameters

    • key

      Specifies the key of the series to write data.

      Example Values: my-custom-key

  • Querystring parameters

    None

  • Request Body

    An array of dictionaries representing a datapoint. You can add as many timestamp/value pairs for the series at a time as you’d like.

  • Response

    A 200 OK if the request completes.

  • Side Effects

    New timestamp/value pairs are written for the given series key.

    A new series is created if the key did not previously exist.

  • Example Request

    post/series/key/my-custom-key/data/post data
    1. [
    2. {"t":"2012-01-08T00:21:54.000+0000","v":4.164},
    3. {"t":"2012-01-08T00:21:55.000+0000","v":3.121},
    4. {"t":"2012-01-08T00:21:56.000+0000","v":3.629}
    5. ]

Bulk Write Multiple Series

  • Description

    Writes data to multiple series at the same timestamp.

    Series can be referenced by either id or key. A timestamp and an array of id/key and value pairs are sent in the request body. This is useful for storing multiple measurements at a single time, for example, temperature, humidity, and barometric pressure from a thermostat.

  • Resource URL

    POST/data/
  • URL Parameters

    None

  • Querystring parameters

    None

  • Request Body

    A JSON object with a timestamp ("t") and an array of objects containing series identifiers (id/key) and values.

  • Response

    A 200 OK if the request completes.

  • Side Effects

    New timestamp/value pairs are written for the given series ids and keys.

    A new series is created if a key did not previously exist.

  • Example Request

    post/data/post data
    1. {
    2. "t":"2012-01-08T00:21:54.000+0000",
    3. "data":[
    4. {"id":"01868c1a2aaf416ea6cd8edd65e7a4b8","v":4.164},
    5. {"id":"38268c3b231f1266a392931e15e99231","v":73.13},
    6. {"key":"your-custom-key","v":55.423},
    7. {"key":"foo","v":324.991},
    8. ]
    9. }