Language

DataPlugs are the microservices that bring data from other digital resources into HATs. However, to ensure users’ privacy in the distributed ecosystem, DEX requires DataPlugs to be registered before they can be plugged into a HAT.

DEX records some basica data about every plug:

ParameterDescriptionRequired/Generated
uuidUUID of the DataPlugemGenerated
providerIddate when the field was createdGenerated
createddate when the DataPlug was registeredGenerated
nameAlpha-numerical name of the PlugRequired
descriptionTextual description of what the Plug DoesRequired
urlAddress of the plug for users to visit to connectRequired
illustrationUrlLogo of the plug, typically shown in the UI for connecting plugsRequired
passwordHashHash of the DataPlug’s password, set up with a HAT when connectingRequired
approvedWhether or not the plug has been approved within the DEXRequired

To register a new DataPlug, you will need to (contact)[mailto:contact@hatdex.org] us, providing the required details. Your plug will then be reviewed to check if it matches the ecosystem’s privacy requirements, only sends the personal data to the users’ HATs and nowhere else, actually works, etc.

Listing DataPlugs

All DataPlugs are public, listed by the DEX:

curl --request GET \
  --url https://dex.hubofallthings.com/api/dataplugs \
  --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://dex.hubofallthings.com/api/dataplugs");
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://dex.hubofallthings.com/api/dataplugs",
  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://dex.hubofallthings.com/api/dataplugs"

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://dex.hubofallthings.com/api/dataplugs")

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

Providing a list of all DataPlugs and their details.

Connecting a DataPlug

Because the HATs are distributed and are likely to be created before you register your own DataPlug, HATs do not necessarily recognise the plug and your authentication would fail initially. When your DataPlug is registered, you as the owner of the plug receive a set of credentials to use with the DEX and your account is associated with the plug as the “owner” account. Before you can connect to a HAT, you need to ask DEX to connect:

curl --request GET \
  --url https://dex.hubofallthings.com/api/dataplugs/DATAPLUG_ID/connect \
  --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://dex.hubofallthings.com/api/dataplugs/DATAPLUG_ID/connect");
xhr.setRequestHeader("x-auth-token", "ACCESS_TOKEN");

xhr.send(data);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://dex.hubofallthings.com/api/dataplugs/DATAPLUG_ID/connect",
  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(
    "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://dex.hubofallthings.com/api/dataplugs/DATAPLUG_ID/connect"

headers = {'x-auth-token': 'ACCESS_TOKEN'}

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

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

url = URI("https://dex.hubofallthings.com/api/dataplugs/DATAPLUG_ID/connect")

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["x-auth-token"] = 'ACCESS_TOKEN'

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

Once DEX responds with 200 OK status and a message saying that the DataPlug has been connected, you can connect directly to the HAT with username matching the name of your plug and the password corresponding to the passwordHash.