Dimensions

You can add Dimensions to your data items. Any property string that does not start with ‘$’ (reserved for metric key identifiers) and is not equal to ‘date’ or ‘unit’ will be recognized as a dimension.

In the example below, we’ve split the metric based on the Dimension ‘Channel’

  • cURL
  • PHP
  • JavaScript
  • Java
  • Go
  • Python
  • C#

curl https://push.databox.com \
-u <your_token>: \
-X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.databox.v2+json' \
-d '{
  "data":[
    {
      "$sales": 8300,
      "channel": "online"
    },
    {
      "$sales": 4000,
      "channel": "retail"
    },
    {
      "$sales": 1230,
      "$costs": 4567,
      "channel": "in-person"
    }
  ]
}'

<?php

require_once __DIR__ . '/../../../vendor/autoload.php';

use Databox\Api\DefaultApi;
use Databox\ApiException;
use Databox\Configuration;
use Databox\Model\PushData as DataboxPushData;
use GuzzleHttp\Client;

execute();

function execute()
{
    // Configure HTTP basic authorization: basicAuth
    $config = Configuration::getDefaultConfiguration()
        ->setHost('https://push.databox.com')
        ->setUsername('<your_token>');

    $headers = [
        'Content-Type' => 'application/json',
        'Accept'       => 'application/vnd.databox.v2+json'
    ];

    $apiInstance = new DefaultApi(
        new Client(['headers' => $headers]),
        $config
    );

    try {
        $apiInstance->dataPost([
            (new DataboxPushData())
                ->setKey('sales')
                ->setValue(8300)
                ->setAttributes(['channel' => 'online']),
            
            (new DataboxPushData())
                ->setKey('sales')
                ->setValue(4000)
                ->setAttributes(['channel' => 'retail']),
            
                (new DataboxPushData())
                ->setKey('sales')
                ->setValue(1234)
                ->setAttributes(['channel' => 'in-person']),
        ]);

        echo "Successfully pushed data to Databox";
    } catch (ApiException $e) {
        echo 'Exception when calling DefaultApi->dataPost: ' . $e->getMessage() . PHP_EOL . $e->getResponseBody() . PHP_EOL;
    }
}


import {
  ApiResponse,
  Configuration,
  DataPostRequest,
  DefaultApi,
} from "databox";

const config: Configuration = new Configuration({
  basePath: "https://push.databox.com",
  username: "<your_token>",
  headers: {
    Accept: "application/vnd.databox.v2+json",
  },
});

const dataPostRequest: DataPostRequest = {
  pushData: [
    {
      key: "sales",
      value: 8300,
      attributes: [
        {
          key: "channel",
          value: "online"
        }
      ],
    },
    {
      key: "sales",
      value: 4000,
      attributes: [
        {
          key: "channel",
          value: "retail"
        },
      ]
    },
    {
      key: "sales",
      value: 1230,
      attributes: [
        {
          key: "channel",
          value: "in-person"
        },
      ]
    }
  ],
};

const api = new DefaultApi(config);

try {
  api
    .dataPostRaw(dataPostRequest)
    .then((response: ApiResponse<void>) => response.raw.json())
    .then((responseBody) => {
      console.log("Response data", responseBody);
    });
} catch (error) {
  console.log("Error: ", error);
}


import org.databox.ApiClient;
import org.databox.ApiException;
import org.databox.Configuration;
import org.databox.api.DefaultApi;
import org.databox.auth.HttpBasicAuth;
import org.openapitools.client.model.PushData;

import java.util.List;

public class PushDataExample {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://push.databox.com");
        defaultClient.addDefaultHeader("Accept", "application/vnd.databox.v2+json");

        HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
        basicAuth.setUsername("<your_token>");

        DefaultApi apiInstance = new DefaultApi(defaultClient);

        try {
            apiInstance.dataPost(List.of(
                new PushData()
                    .key("sales")
                    .value(8300)
                    .attributes(List.of(new PushDataAttribute().key("channel").value("online"))),
                
                new PushData()
                    .key("sales")
                    .value(4000)
                    .attributes(List.of(new PushDataAttribute().key("channel").value("retail"))),

                new PushData()
                    .key("sales")
                    .value(1234)
                    .attributes(List.of(new PushDataAttribute().key("channel").value("in-person")))
            ));
        } catch (ApiException e) {
            e.printStackTrace();
        }
    }
}



// Example not available yet, check other languages

# Example not available yet, check other languages

// Example not available yet, check other languages

Pro Tip: If you send one Dimension with multiple metrics, the dimension will be added to each metric.

In Databox, you can filter and visualize your data for specific dimensions. That means you could view only retail sales, or compare sales across different channels. You can add as many dimensions as you’d like to each metric.

Next step: Units