Language

In this guide we only look at retrieving simple data that is only available to the owner of the HAT and hence usable only by certified dashboard applications. For other kinds of data access, jump to the section on consented data exchange where you will find further pointers.

In the simple case, data from the HAT is retrieved using a GET request to the /api/v2/data/namespace/endpoint.

The endpoint takes the following parameters:

ParameterDefaultMeaning
take1000Limit to how many records the requester will take
skip0How many records to skip - used together with take to implement data paging
orderByThe field in the JSON structure according to which data should be ordered. If, for example, you wish to order data by time, we recommend to include UNIX timestamp in the data as a number
recordIdID of the record when looking up data for one specific item
curl --request GET \
  --url 'https://test.hubat.net/api/v2/data/hat/locations?take=3' \
  --header 'content-type: application/json' \
  --header 'x-auth-token: ACCESS_TOKEN'
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://test.hubat.net/api/v2/data/hat/locations?take=3");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-auth-token", "ACCESS_TOKEN");

xhr.send(data);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://test.hubat.net/api/v2/data/hat/locations?take=3",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/json",
    "x-auth-token: ACCESS_TOKEN"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://test.hubat.net/api/v2/data/hat/locations"

headers = {
    'content-type': "application/json",
    'x-auth-token': "ACCESS_TOKEN"
    }

response = requests.request("GET", url, headers=headers)

print(response.text)
require 'uri'
require 'net/http'

url = URI("https://test.hubat.net/api/v2/data/hat/locations?take=3")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["x-auth-token"] = 'ACCESS_TOKEN'

response = http.request(request)
puts response.read_body

Which returns top 3 results sorted by default ordering:


HTTP/1.1 200 OK
Content-Type: application/json


[
  {
    "endpoint": "rumpel/locations",
    "recordId": "e965e022-6613-476a-a0cd-1f587a41b148",
    "data": {
      "id": 85998,
      "data": {
        "locations": {
          "accuracy": "10.0",
          "latitude": "51.671358277138",
          "longitude": "0.101014673709963",
          "timestamp": "2017-04-23T16:11:17+0000"
        }
      },
      "name": "record 1",
      "lastUpdated": "2017-04-23T16:11:17.000Z"
    }
  },
  {
    "endpoint": "rumpel/locations",
    "recordId": "fcf1a26b-e49f-4457-915b-156e14140f38",
    "data": {
      "id": 85996,
      "data": {
        "locations": {
          "accuracy": "1414.0",
          "latitude": "51.674001392439",
          "longitude": "0.100905202634514",
          "timestamp": "2017-04-23T16:12:58+0000"
        }
      },
      "name": "record 2",
      "lastUpdated": "2017-04-23T16:12:58.000Z"
    }
  },
  {
    "endpoint": "rumpel/locations",
    "recordId": "8f7afa92-39e2-48ab-8028-f5aebaa9918e",
    "data": {
      "id": 85997,
      "data": {
        "locations": {
          "accuracy": "1414.0",
          "latitude": "51.6658257133844",
          "longitude": "0.080477950927866",
          "timestamp": "2017-04-23T16:18:04+0000"
        }
      },
      "name": "record 3",
      "lastUpdated": "2017-04-23T16:18:04.000Z"
    }
  }
]