Create a signal

POST /signals

A signal can be created by making a POST HTTP request. A zone can be targeted in 3 different ways. To know more about the zones please read this understand zoneId In all the cases the attribute to define the zone will be zoneId

Request parameters

Parameter Description
name Required string 'Apple Stock increase'

Name of the Signal

message string 'Lucky you! Apple stock is greater than $500'

Message of the Signal

zoneId Required string 'KEY_Q' '74' '2,2'

Specify the id of the zone targeted by the Signal

color Required string '#FF0000'

Color of the Signal - has to begin by the character ‘#’ and be followed by 3 or 6 hexadecimal digits

effect string 'SET_COLOR' 'BLINK' 'BREATHE' 'COLOR_CYCLE'

Effect of the Signal

pid Required string 'DK5QPID'

Pid of the device targeted by the signal

isArchived boolean false

Indicates if the Signal has been archived

Ignored when using localhost

isRead boolean false

Indicates if the Signal has been read

Ignored when using localhost

isMuted boolean false

Not implemented yet

clientName string 'Local Node Script' 'Zapier'

Describes the client that created the signal

Request

BACKEND_URL="https://q2.daskeyboard.com"

HEADERS=(-H "X-API-KEY: $API_KEY" -H "Content-Type: application/json")
URL="$BACKEND_URL/api/1.0/signals"

curl "${HEADERS[@]}" -X POST -d  '{
  "zoneId": "KEY_Q",
  "color": "#FF0000",
  "effect": "SET_COLOR",
  "pid": "DK5QPID",
  "clientName": "Shell script",
  "message": "Q App version 3 is available. Download it at https://www.daskeyboard.io/get-started/download/",
  "name": "New Q app version available"}' $URL

 Copy

 Edit Script

var backendUrl = 'https://q2.daskeyboard.com';
var headers = {
    "Content-Type": "application/json",
    "X-API-KEY": "$API_KEY"
  }
// Library to make simplified HTTP client requests
// if not installed run npm install request
var request = require('request');

// Construct the signal to send
var signal = {
    'zoneId': 'KEY_Q',
    'color': '#FF0000',
    'effect': 'SET_COLOR',
    'pid': 'DK5QPID',
    'clientName': 'Node script',
    'message': 'Q App version 3 is available. Download it at https://www.daskeyboard.io/get-started/download/',
    'name': 'New Q app version available'
};
// HTTP POST request to the cloud
request.post({
    url: backendUrl + '/api/1.0/signals',
    headers: headers,
    body: signal,
    json: true
}, function (error, response) {
    // OK
    if (response && response.statusCode == 200) {
        console.log('response', response.body);
    }
        // OK from API response
    if(response && response.statusCode != 200){
        console.error(response.body);
    }
    // OK
    if (error) {
        console.error(error);
    }
});

 Copy

 Edit Script


backendUrl = 'https://q2.daskeyboard.com'

headers = { "Content-type": "application/json","X-API-KEY": "uS3qbfUi5sFNq2GU1j7EaAQkgdft0Zwg"}
import json
# sudo pip install request
import requests

# Construct the signal to send
signal = {
    'zoneId': 'KEY_Q',
    'color': '#FF0000',
    'effect': 'SET_COLOR',
    'pid': 'DK5QPID',
    'clientName': 'Python script',
    'message': 'Q App version 3 is available. Download it at https://www.daskeyboard.io/get-started/download/',
    'name': 'New Q app version available'
}


signal_json = json.dumps(signal)

# sending the signal

res_signal = requests.post(backendUrl + '/api/1.0/signals', data=signal_json, headers=headers)

# checking the response
if res_signal.ok:
    print "OK"
    print res_signal.text
else:
    print "Error: " + res_signal.text

 Copy

 Edit Script

BACKEND_URL="http://localhost:27301"
HEADERS=(-H "Content-Type: application/json")
URL="$BACKEND_URL/api/1.0/signals"

curl "${HEADERS[@]}" -X POST -d  '{
  "zoneId": "KEY_Q",
  "color": "#FF0000",
  "effect": "SET_COLOR",
  "pid": "DK5QPID",
  "clientName": "Shell script",
  "message": "Q App version 3 is available. Download it at https://www.daskeyboard.io/get-started/download/",
  "name": "New Q app version available"}' $URL

 Copy

 Edit Script

var backendUrl = 'http://localhost:27301';
var headers = {
    "Content-Type": "application/json"
  }
// Library to make simplified HTTP client requests
// if not installed run npm install request
var request = require('request');

// Construct the signal to send
var signal = {
    'zoneId': 'KEY_Q',
    'color': '#FF0000',
    'effect': 'SET_COLOR',
    'pid': 'DK5QPID',
    'clientName': 'Node script',
    'message': 'Q App version 3 is available. Download it at https://www.daskeyboard.io/get-started/download/',
    'name': 'New Q app version available'
};
// HTTP POST request to the cloud
request.post({
    url: backendUrl + '/api/1.0/signals',
    headers: headers,
    body: signal,
    json: true
}, function (error, response) {
    // OK
    if (response && response.statusCode == 200) {
        console.log('response', response.body);
    }
        // OK from API response
    if(response && response.statusCode != 200){
        console.error(response.body);
    }
    // OK
    if (error) {
        console.error(error);
    }
});

 Copy

 Edit Script

backendUrl = 'http://localhost:27301'
headers = { "Content-type": "application/json"}
import json
# sudo pip install request
import requests

# Construct the signal to send
signal = {
    'zoneId': 'KEY_Q',
    'color': '#FF0000',
    'effect': 'SET_COLOR',
    'pid': 'DK5QPID',
    'clientName': 'Python script',
    'message': 'Q App version 3 is available. Download it at https://www.daskeyboard.io/get-started/download/',
    'name': 'New Q app version available'
}


signal_json = json.dumps(signal)

# sending the signal

res_signal = requests.post(backendUrl + '/api/1.0/signals', data=signal_json, headers=headers)

# checking the response
if res_signal.ok:
    print "OK"
    print res_signal.text
else:
    print "Error: " + res_signal.text

 Copy

 Edit Script

Response
HTTP 200
{
  "id": 392,
  "name": "New Q app version available",
  "message": "Q App version 3 is available. Download it at https://www.daskeyboard.io/get-started/download/",
  "zoneId": "KEY_Q",
  "color": "#FF0000",
  "effect": "SET_COLOR",
  "pid": "DK5QPID",
  "isArchived": false,
  "isRead": false,
  "isMuted": false,
  "userId": 9,
  "clientName": "Local Node script",
  "createdAt": 1531946199392,
  "updatedAt": 1531946199392
}