Language

The DEX (data exchange) service of HATDeX consists of:

  • Data Exchange processes
  • Data Transaction Logging, and statistics across the ecosystem
  • HAT Access brokering for applications and develoeprs

These processes log all activities in the HAT ecosystem, responds to HAT requests to create Data Debits, installs Data Plugs, holds data transactions, verifies exchanges and quickly, accurately and securely sends and receives data between parties.

It reports the ecosystem statistics as well as integrating datasets and data services for third parties into the system.

The core aspects are:

  1. Statistics logging and reporting
  2. Data Plug management
  3. Data Offer brokering and setup
  4. New HAT onboarding

Together they provide functionality for most applications to benefit from the Data Exchange, however if your needs aren’t covered here, or if you need some help working out what you need, just get in touch!

Authentication

DEX uses the same authentication methods as the HAT. When your DEX account is created, you are given a username and a password, which you use to retrieve an access_token:

curl --request GET \
  --url https://dex.hubofallthings.com/api/users/access_token \
  --header 'password: DEX_PASSWORD' \
  --header 'username: DEX_USERNAME'
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://dex.hubofallthings.com/api/users/access_token");
xhr.setRequestHeader("username", "DEX_USERNAME");
xhr.setRequestHeader("password", "DEX_PASSWORD");

xhr.send(data);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://dex.hubofallthings.com/api/users/access_token",
  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(
    "password: DEX_PASSWORD",
    "username: DEX_USERNAME"
  ),
));

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

curl_close($curl);

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

url = "https://dex.hubofallthings.com/api/users/access_token"

headers = {
    'username': "DEX_USERNAME",
    'password': "DEX_PASSWORD"
    }

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

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

url = URI("https://dex.hubofallthings.com/api/users/access_token")

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["username"] = 'DEX_USERNAME'
request["password"] = 'DEX_PASSWORD'

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

You use this token for all subsequent API requests to DEX by including it as a X-Auth-Token header.