Databox API wrapper for Java
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample
src
.editorconfig
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
build.gradle

README.md

Databox Java SDK

Build Status Download

The Java SDK for interacting with the Databox Push API v 2.3.

Installation

For Gradle users. Add this to your gradle.build:

repositories {
  jcenter()
  maven { url "http://dl.bintray.com/databox/databox" }
}

dependencies {
  ...
  compile 'com.databox:databox-java:2.3'
  ...
}

For Maven users. Get your settings.xml at Bintray.

Or check out the sample/ directory for both Maven and Gradle samples. You can build them like:

mvn clean install mvn exec:java -Dexec.mainClass="com.databox.sdk.sample.DataboxSample"

gradle build

Requirements

  • Java >= 1.7 or later,
  • Maven >= 3.0.3 OR Gradle 2.x

Usage

String TOKEN = "your_token_goes_here";
Databox databox = new Databox(TOKEN);
try {
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
	databox.push("kitchen_light", 341d, sdf.parse("2015-12-25 00:00:00"));
} catch (Exception e) {
	logger.error(e.getLocalizedMessage(), e);
}

Usage (with attributes)

String TOKEN = "your_token_goes_here";
Databox databox = new Databox(TOKEN);
try {
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
	Databox.KPI kpi = new Databox.KPI()
		.setKey("switch")
		.setValue(0d)
		.addAttribute("kitchen", 125)
		.addAttribute("living_room", 412);
		
	databox.push(kpi);
} catch (Exception e) {
	logger.error(e.getLocalizedMessage(), e);
}

Sending multiple metrics at once

String TOKEN = "your_token_goes_here";
Databox databox = new Databox(TOKEN);
try {
	List<Databox.KPI> kpis = new ArrayList<Databox.KPI>();
	kpis.add(new Databox.KPI().setKey("my_first_key").setValue(1201.41));
	kpis.add(new Databox.KPI().setKey("my_second_key").setValue(8249));
	databox.push(kpis);
} catch (Exception e) {
	logger.error(e.getLocalizedMessage(), e);
}

Retrieving last pushes

Databox databox = new Databox(TOKEN);
try {
    StringBuffer lastPush = databox.lastPush(); // just last one
    System.out.println(lastPush);
    
    StringBuffer lastPushes = databox.lastPushes(5); // last 5 pushes
    System.out.println(lastPushes);    
} catch (Exception e) {
	logger.error(e.getLocalizedMessage(), e);
}

License

Licensed under the MIT License.

Authors