The Wia Developer Hub

Welcome to the Wia developer hub. You'll find comprehensive guides and documentation to help you start working with Wia as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    
Suggest Edits

Getting Started

 

The Wia REST API lets you create events from any device or build your own application.

We have native libraries for most use cases (Javascript, Python, iOS, etc.) that are all built for high-performance and are open-source.

Suggest Edits

Endpoints

 

The endpoints for the REST API are:

Secure: https://api.wia.io/v1 (port 443)
Unsecure: http://api.wia.io/v1 (port 80)

Suggest Edits

Authentication

 

For most actions, an access token is required to communicate with the Wia REST API.

Device

Authenticate to the REST API by sending your device's secret key along with a request. Authentication uses HTTP Bearer Tokens, which involves a the key (which begins with d_sk) and prepended with the string ‘Bearer ‘ e.g. Bearer d_sk_abc123. This is generated in the Wia dashboard when you create a device. You can find it in Device > Configuration.

With a Device Key, you can publish Events and Locations via the REST API

 

A number of headers must be sent along with each request. For authentication, Authorization: Bearer {device-secret-key}

Content-Type

In order to send data to our REST API, a content-type header must be set to application/json.

We currently return a 200 response for all API requests so debugging should be done in the Wia Debugger. The only exception is if the request is invalid it will respond with a 400.

We’re hard at work surfacing more errors and more helpful responses to our users. If you have any suggestions, please contact us.

Suggest Edits

(Deprecated) Access Tokens

 

(Deprecated) Access tokens are used to allow users to communicate with the Wia APIs. The same token can be used across REST, MQTT and Websocket for different purposes.

Suggest Edits

(Deprecated) Generate an Access Token

 
posthttps://api.wia.io/v1/auth/token
curl --request POST \
  --url https://api.wia.io/v1/auth/token \
  --header 'x-app-key: x-app-key'
var request = require("request");

var options = { method: 'POST',
  url: 'https://api.wia.io/v1/auth/token',
  headers: { 'x-app-key': 'x-app-key' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/auth/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-app-key"] = 'x-app-key'

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/auth/token");
xhr.setRequestHeader("x-app-key", "x-app-key");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/auth/token"

headers = {'x-app-key': 'x-app-key'}

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

username
string
required

Username of the user. This is usually their email address.

password
string
required

Password of the user.

scope
string
required

Scope of the token. Default is 'user'.

grantType
string
required

Grant type of the token. Default is 'password'.

Headers

x-app-key
string
required

Desktop or mobile application key.

 
Suggest Edits

(Deprecated) Revoke an Access Token

 
posthttps://api.wia.io/v1/auth/token/revoke
curl --request POST \
  --url https://api.wia.io/v1/auth/token/revoke
var request = require("request");

var options = { method: 'POST',
  url: 'https://api.wia.io/v1/auth/token/revoke' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/auth/token/revoke")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/auth/token/revoke");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/auth/token/revoke"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

token
string
required

The access token to revoke.

 

Events are interactions from your device e.g. temperature, humidity, door opened, etc.

Suggest Edits

Create an Event

 

Header Auth

 Authentication is required for this endpoint.
posthttps://api.wia.io/v1/events
curl --request POST \
  --url https://api.wia.io/v1/events
var request = require("request");

var options = { method: 'POST', url: 'https://api.wia.io/v1/events' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/events")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/events");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/events"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

name
string
required

Name of the event

data
mixed type

Data of the event

file
file

File to add to the event

 

Create an Event as a Server Application

It is also possible to create an event as a server application via the REST API or SDKs. Simply add the device parameter with the ID of the device you would like to send the event for.

If you wish to use your own identifier, then use the parameter customId instead of id. This will automatically create the device in Wia if it does not already exist.

var wia = require('wia')({
  appKey: 'a_sk_abc123'
});

wia.events.publish({
  name: 'humidity',
  data: 44.54,
  device: {
    id: 'dev_asdf43' 
  }
});
Suggest Edits

Retrieve an Event

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/events/id
curl --request GET \
  --url https://api.wia.io/v1/events/id
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/events/id' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/events/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/events/id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/events/id"

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Path Params

id
string
required

Identifier of the event to retrieve.

 
Suggest Edits

List Events

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/events
curl --request GET \
  --url 'https://api.wia.io/v1/events?device.id=device.id'
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/events',
  qs: { 'device.id': 'device.id' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/events?device.id=device.id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/events?device.id=device.id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/events"

querystring = {"device.id":"device.id"}

response = requests.request("GET", url, params=querystring)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Query Params

device.id
string
required

ID of the device to list events for.

name
string

Name of the event to filter by.

limit
int32

Number of events to return.

page
int32

Page of events to return.

order
string

Field to order the list by.

sort
string

Sort by descending or ascending.

since
date-time

Since date of events.

until
date-time

Until date of events.

 
Suggest Edits

Locations

 
Suggest Edits

Create a Location

 

Header Auth

 Authentication is required for this endpoint.
posthttps://api.wia.io/v1/locations
curl --request POST \
  --url https://api.wia.io/v1/locations
var request = require("request");

var options = { method: 'POST', url: 'https://api.wia.io/v1/locations' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/locations")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/locations");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/locations"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

latitude
double
required

Latitude coordinate of the location.

longitude
double
required

Longitude coordinate of the location.

altitude
double

Altitude of the location.

 

Create a Location as a Server Application

It is also possible to create a location as a server application via the REST API or SDKs. Simply add the device parameter with the ID of the device you would like to send the event for.

If you wish to use your own identifier, then use the parameter customId instead of id. This will automatically create the device in Wia if it does not already exist.

var wia = require('wia')({
  appKey: 'a_sk_abc123'
});

wia.locations.publish({
  latitude: 35.694319,
  longitude: 139.702843,
  device: {
    id: 'dev_asdf43' 
  }
});
Suggest Edits

Retrieve a Location

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/locations/id
curl --request GET \
  --url https://api.wia.io/v1/locations/id
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/locations/id' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/locations/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/locations/id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/locations/id"

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Path Params

id
string
required

Identifier of the location to retrieve.

 
Suggest Edits

List Locations

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/locations
curl --request GET \
  --url 'https://api.wia.io/v1/locations?device.id=device.id'
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/locations',
  qs: { 'device.id': 'device.id' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/locations?device.id=device.id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/locations?device.id=device.id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/locations"

querystring = {"device.id":"device.id"}

response = requests.request("GET", url, params=querystring)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Query Params

device.id
string
required

ID of the device to list events for.

limit
int32

Number of events to return.

page
int32

Page of events to return.

order
string

Field to order the list by.

sort
string

Sort by descending or ascending.

since
date-time

Since date of events.

until
date-time

Until date of events.

 

Suggest Edits

Create a Space

 

Header Auth

 Authentication is required for this endpoint.
posthttps://api.wia.io/v1/spaces
curl --request POST \
  --url https://api.wia.io/v1/spaces
var request = require("request");

var options = { method: 'POST', url: 'https://api.wia.io/v1/spaces' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/spaces")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/spaces");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/spaces"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

name
string
required

Name of the space

 
Suggest Edits

Retrieve a Space

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/spaces/id
curl --request GET \
  --url https://api.wia.io/v1/spaces/id
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/spaces/id' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/spaces/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/spaces/id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/spaces/id"

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Path Params

id
string
required

ID of the space

 
Suggest Edits

List Spaces

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/spaces
curl --request GET \
  --url https://api.wia.io/v1/spaces
var request = require("request");

var options = { method: 'GET', url: 'https://api.wia.io/v1/spaces' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/spaces")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/spaces");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/spaces"

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Query Params

limit
int32

Number of spaces to return.

page
int32

Page of events to return.

order
string

Field to order the list by.

sort
string

Sort by descending or ascending.

 
 
Suggest Edits

Create a Device

 

Header Auth

 Authentication is required for this endpoint.
posthttps://api.wia.io/v1/devices
curl --request POST \
  --url https://api.wia.io/v1/devices
var request = require("request");

var options = { method: 'POST', url: 'https://api.wia.io/v1/devices' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/devices")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/devices");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/devices"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

name
string
required

Name of the device

customId
string

Custom ID of the device. This lets you create your own ID that you can search for the device for.

space
object
required

Space to add the device to

 
space.id
string
required

ID of the space

 
Suggest Edits

Retrieve a Device

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/devices/id
curl --request GET \
  --url https://api.wia.io/v1/devices/id
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/devices/id' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/devices/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/devices/id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/devices/id"

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Path Params

id
string
required

ID of the device

 
Suggest Edits

List Devices

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/devices
curl --request GET \
  --url 'https://api.wia.io/v1/devices?space.id=space.id'
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/devices',
  qs: { 'space.id': 'space.id' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/devices?space.id=space.id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/devices?space.id=space.id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/devices"

querystring = {"space.id":"space.id"}

response = requests.request("GET", url, params=querystring)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Query Params

space.id
string
required

ID of space to list devices for.

limit
int32

Number of devices to return.

page
int32

Page of events to return.

order
string

Field to order the list by.

sort
string

Sort by descending or ascending.

 
 
Suggest Edits

Create a command

 

Header Auth

 Authentication is required for this endpoint.
posthttps://api.wia.io/v1/commands
curl --request POST \
  --url https://api.wia.io/v1/commands
var request = require("request");

var options = { method: 'POST', url: 'https://api.wia.io/v1/commands' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/commands")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/commands");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/commands"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

name
string
required

Name of the command

device
object
required

device to add the command to

 
device.id*
string

ID of the object

 
Suggest Edits

Retrieve a command

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/commands/id
curl --request GET \
  --url https://api.wia.io/v1/commands/id
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.wia.io/v1/commands/id' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/commands/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/commands/id");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/commands/id"

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Path Params

id
string
required

Id of the command

 
Suggest Edits

List commands

 

Header Auth

 Authentication is required for this endpoint.
gethttps://api.wia.io/v1/commands
curl --request GET \
  --url https://api.wia.io/v1/commands
var request = require("request");

var options = { method: 'GET', url: 'https://api.wia.io/v1/commands' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/commands")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("GET", "https://api.wia.io/v1/commands");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/commands"

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

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

device
object
 
device.id
string
required

ID of the device

limit
int32

number of commands to return

page
int32

page of commands to return

order
string

Field to order the list by.

sort
string

Sort by descending or ascending.

 
Suggest Edits

Run a command

 

Header Auth

 Authentication is required for this endpoint.
posthttps://api.wia.io/v1/commands/run
curl --request POST \
  --url https://api.wia.io/v1/commands/run
var request = require("request");

var options = { method: 'POST', url: 'https://api.wia.io/v1/commands/run' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
require 'uri'
require 'net/http'

url = URI("https://api.wia.io/v1/commands/run")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
var data = JSON.stringify(false);

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

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

xhr.open("POST", "https://api.wia.io/v1/commands/run");

xhr.send(data);
import requests

url = "https://api.wia.io/v1/commands/run"

response = requests.request("POST", url)

print(response.text)
A binary file was returned

You couldn't be authenticated

Try the API to see results

Body Params

slug
string
required

slug of the command

device
object
 
device.id
object
required

device associated with the command

 
device.id.id*
string

ID of the object

 
Suggest Edits

Getting Started

 

The Wia MQTT API lets you publish and subscribe to events and locations.

We have native libraries for most use cases (Javascript, Python, iOS, etc.) that are all built for high-performance and are open-source.

Suggest Edits

Endpoints

 

The endpoints for the MQTT API are:

Unsecure: mqtt://api.wia.io (port 1883)
Secure: mqtts://api.wia.io (port 8883)

Suggest Edits

Authentication

 

To communicate with the Wia MQTT API an access token is required.

Device

To connect to the MQTT API put your device secret key as the username and a space (blank character) as the password. Your device secret key is generated when you create a device. It should begin with d_sk. You can find it in Device > Configuration.

 

When communicating with the stream, a number of notifications are emitted.

Connect

Emitted on successful connection.

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for a successful connection to the MQTT API
wia.stream.on('connect', function() {
  console.log("Connected to the stream!");
});

Reconnect

Emitted when a reconnect starts.

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for a reconnection
wia.stream.on('reconnect', function() {
  console.log("Reconnect emitted.");
});

Disconnect

Emitted after a disconnection.

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for a disconnection
wia.stream.on('disconnect', function() {
  console.log("Disconnect emitted.");
});

Offline

Emitted when the client goes offline.

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for an offline
wia.stream.on('offline', function() {
  console.log("Offline emitted.");
});

Error

Emitted when a client cannot connect or a parsing error occurs.

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for a error
wia.stream.on('error', function(err) {
  console.log("Error emitted.");
  console.log(err);
});

Events are interactions from your device e.g. temperature, humidity, door opened, etc.

Suggest Edits

Publish an Event

 

To send an event to Wia, connect to the MQTT API and publish it to the events topic.

The events MQTT topic is:
events or devices/{DEVICE_ID}/events/{EVENT_NAME}

Example code

Publish an Event using the Wia SDK

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for a successful connection to the MQTT API
wia.stream.on('connect', function() {
  // Publish an event
  wia.events.publish({
    name: 'temperature',
    data: 21.5
  });
});

// Connect to the MQTT API
wia.stream.connect();
Suggest Edits

Subscribe to Events

 

To subscribe to events from a device, connect to the MQTT API and subscribe it to the events topic for that device.

To subscribe to all events the MQTT topic is:
devices/{device.id}/events/+

To subscribe to a specific event the MQTT topic is:
devices/{device.id}/events/{event.name}

Replace {device.id} with your device ID (should begin with dev_) and {event.name} with the name of the event you wish to subscribe to.

Example Code

Subscribe to all events using the Wia SDK

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Subscribe to all events for a device
// Replace 'dev_abc123' with your device ID
wia.events.subscribe({
  device: {
  	id: 'dev_abc123'
  }
}, function(err, event) {
  console.log(event);
});

// Connect to the MQTT API
wia.stream.connect();

Subscribe to only temperature events using the Wia SDK

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Subscribe to just 'temperature' events for a device
// Replace 'dev_abc123' with your device ID
wia.events.subscribe({
  device: {
  	id: 'dev_abc123'
  },
  name: 'temperature'
}, function(err, event) {
  console.log(event);
});

// Connect to the MQTT API
wia.stream.connect();
Suggest Edits

Locations

 
Suggest Edits

Publish a Location

 

To send a location to Wia, connect to the MQTT API and publish it to the locations topic.

The events MQTT topic is:
locations or devices/{DEVICE_ID}/locations

Example Code

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for a successful connection to the MQTT API
wia.stream.on('connect', function() {
  // Publish a location
  wia.locations.publish({
    latitude: 35.689487,
    longitude: 139.691706
  });
});

// Connect to the MQTT API
wia.stream.connect();
Suggest Edits

Subscribe to Locations

 

To subscribe to locations from a device, connect to the MQTT API and subscribe it to the locations topic for that device.

To subscribe to locations the MQTT topic is:
devices/{device.id}/locations

Replace {device.id} with your device ID (should begin with dev_).

Example Code

Subscribe to all device locations using the Wia SDK

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Subscribe to all locations for a device
// Replace 'dev_abc123' with your device ID
wia.locations.subscribe({
  device: {
  	id: "dev_abc123'
  }
}, function(err, location) {
  console.log(location);
});

// Connect to the MQTT API
wia.stream.connect();
 
Suggest Edits

Run a Comand

 

To run a Command, connect to the MQTT API and publish it to the commands topic.

The events MQTT topic is:
commands or devices/{DEVICE_ID}/commands/{COMMAND_SLUG}

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Listen for a successful connection to the MQTT API
wia.stream.on('connect', function() {
  // Run a Command
  wia.commmands.run({
    slug: 'say-hello', 
    device: {
  		id: "dev_abc123'
  	}
  });
});

// Connect to the MQTT API
wia.stream.connect();
Suggest Edits

Subscribe to a Command

 

To subscribe to commands from a device, connect to the MQTT API and subscribe it to the command topic for that device.

To subscribe to a specific event the MQTT topic is:
devices/{device.id}/commands/{command.slug}/run

Replace {device.id} with your device ID (should begin with dev_) and {command.slug} with the slug of the command you wish to subscribe to

// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');

// Subscribe to a command 
// replace say-hello with your command slug
wia.commands.subscribe({
	slug: 'say-hello'
}, function(err, data) {
	console.log(data);
});

// Connect to the MQTT API
wia.stream.connect();
Suggest Edits

Getting Started

 

The Wia CoAP API lets you publish events and locations.

We have native libraries for most use cases (Javascript, Python, iOS, etc.) that are all built for high-performance and are open-source.

Suggest Edits

Endpoints

 

The endpoint for the CoAP API is:

coap://coap.wia.io (port 5683)

For NB-IoT, use the IP address 52.17.209.228. You may need to get this whitelisted by your network operator.

Suggest Edits

Authentication

 

To communicate with the Wia CoAP API an access token is required.

Device

To connect to the CoAP API put your device secret key in the JSON payload of the request as the variable accessToken. Your device secret key is generated when you create a device. It should begin with d_sk. You can find it in Device > Configuration.

Suggest Edits

Packet Structure

 

The following diagram shows the structure of a CoAP packet

CoAP Packet Structure

CoAP Packet Structure

Version (2 bits) - CoAP version. Always 01
T (2 bits) - Transaction type
TKL (4 bits) - Token length
Code (8 bits) - Request or response code

Request codes

Type
Code
Binary

GET

1

00000001

POST

2

00000010

PUT

3

00000011

DELETE

4

00000100

Response codes

Type
Code

Created

2.01

Deleted

2.02

Changed

2.04

Content

2.05

Bad Request

4.00

Unauthorized

4.01

Not found (resource)

4.04

Method not allowed

4.05

Message ID (16 bits) - Unique identifier for the packet. Used for duplicate detection.
Token (up to 64 bits) - Used to match a response with a request
Options (x bits) - Both requests and responses may include a list of one or more options.
Payload Marker (8 bits) - Marks the beginning of the payload. Always 11111111

Example for publishing an event

For this, we are going to show the packet structure of a device publishing an Event to Wia. The packet itself, along with the payload, should be transmitted in hex format.

This shows a POST request (Code: 02) being submitted to the path "events" with the payload structure {“accessToken":"d_sk_abc123","name":"temperature","data":"21"}.

To test with your own device, make a request replacing d_sk_abc123 with your device's access token.

Suggest Edits

Publish an Event

 

To send an event to Wia, connect to the CoAP API and send a POST request to the URL coap://coap.wia.io/events.

Example Code

// Install node coap client using `npm install node-coap-client`
const coap = require("node-coap-client").CoapClient;

// Create the buffer payload
// Replace 'your-device-secret-key' with the secret key for your device
// it should start with `d_sk`
const bufferPayload = Buffer.from(JSON.stringify({
  accessToken: 'your-device-secret-key',
  name: 'temperature',
  data: 21.5
}));

coap
    .request(
        'coap://coap.wia.io:5683',
        'post',
        bufferPayload
    )
    .then(response => {
      console.log(response.payload.toString('utf-8'));
    })
    .catch(err => {
      console.log(err);
    });