0.0.2 • Published 11 years ago

databox v0.0.2

Weekly downloads
354
License
MIT
Repository
github
Last release
11 years ago

Databox

This package is designed to consume the Databox Push API functionality via TypeScript/JavaScript client that utilizes Fetch API. The package is compatible with the following environments:

Environment

  • Node.js
  • Webpack
  • Browserify

Language level

  • ES5 - You must have a Promises/A+ library installed
  • ES6

Module system

  • CommonJS
  • ES6 module system

The package can be used with both TypeScript and JavaScript. In TypeScript, the definitions will be automatically resolved via package.json. (Reference).

Installing

npm install databox --save

Prerequisites

In use the Databox Push API functionality, please refer to Databox Developers Page, specifically the Quick Guide section, where you will learn how to create a Databox Push API token which is required for pushing your data.

Example

The basic example of pushing data to Databox is provided below:

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

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

const dataPostRequest: DataPostRequest = {
  pushData: [
    {
      key: "<Metric_name>",
      value: 123,
      date: "<Date_in_ISO8601>",
      unit: "<Unit>", // Optional
      attributes: [{ key: "<Dimension_name>", value: "<Dimension_value>" }], // Optional
    },
  ],
};

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);
}
2.1.2

11 months ago

2.1.1

11 months ago

2.0.1

9 years ago

2.0.0

9 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago