Language

The final step is to register the HAT with the DEX to allow it to connect dataplugs, sign up for offers and otherwise become a member of the HAT ecosystem.

The only parameter passed to DEX is hatAddress containing the fully-qualified address of the HAT - all other details (such as the HAT’s public key) are fetched by DEX or registration fails if the HAT is not available.

curl --request POST \
  --url https://dex.hubofallthings.com/api/users/registerHat \
  --header 'content-type: application/json' \
  --data '{"hatAddress":"testhat.hubat.net"}'
var data = JSON.stringify({
  "hatAddress": "testhat.hubat.net"
});

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

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

xhr.open("POST", "https://dex.hubofallthings.com/api/users/registerHat");
xhr.setRequestHeader("content-type", "application/json");

xhr.send(data);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://dex.hubofallthings.com/api/users/registerHat",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"hatAddress\":\"testhat.hubat.net\"}",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/json"
  ),
));

$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/registerHat"

payload = "{\"hatAddress\":\"testhat.hubat.net\"}"
headers = {'content-type': 'application/json'}

response = requests.request("POST", url, data=payload, headers=headers)

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

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

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

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\"hatAddress\":\"testhat.hubat.net\"}"

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