Get signals
GET /signals
Fetch a list of signals using pagination
Request parameters
Parameter | Description |
---|---|
page |
string
'0'
'1'
Specify the page number to ferch |
size |
string
'20'
Number of element per page |
sort |
string
'DESC'
'ASC'
Sort order |
Request
BACKEND_URL="https://q2.daskeyboard.com"
HEADERS=(-H "X-API-KEY: $API_KEY" -H "Content-Type: application/json")
# Page to query
PAGE_NUMBER="0"
# Number of elements per page
NUMBER_OF_SIGNALS_PER_PAGE="2"
# Sort order can be ASC or DESC
SORT_ORDER="ASC"
URL="$BACKEND_URL/api/1.0/signals?page=$PAGE_NUMBER&size=$NUMBER_OF_SIGNALS_PER_PAGE&sort=createdAt,$SORT_ORDER"
curl "${HEADERS[@]}" -X GET $URL
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');
// page to query
var pageNumber = 0;
// number of signal per page
var numberOfSignalsPerPage = 2;
// sort order
var sortOrder = 'ASC' // or DESC
var params = '?page=' + pageNumber + '&size=' + numberOfSignalsPerPage
+ '&sort=createdAt,' + sortOrder;
// HTTP GET request to the cloud
request.get({
url: backendUrl + '/api/1.0/signals' + params,
headers: headers,
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);
}
});
backendUrl = 'https://q2.daskeyboard.com'
headers = { "Content-type": "application/json","X-API-KEY": "uS3qbfUi5sFNq2GU1j7EaAQkgdft0Zwg"}
import json
# sudo pip install request
import requests
# Page to query
page_number = 0
# Number of elements per page
number_of_signals_per_page = 2
# Sort order
sort_order = 'ASC' # Or DESC
params = '?page=' + str(page_number) + '&size=' + str(number_of_signals_per_page) + '&sort=createdAt,' + sort_order
res_shadows = requests.get(backendUrl + '/api/1.0/signals' + params, headers=headers)
# checking the response
if res_shadows.ok:
print "OK"
print res_shadows.text
else:
print "Error: " + res_shadows.text
Response
HTTP 200
{
"content": [
{
"id": 1280765,
"zoneId": "KEY_Q",
"pid": "DK5QPID",
"userId": 9,
"name": "New Q app version available",
"message": "Q App version 3 is available. Download it at https: //www.daskeyboard.io/get-started/download/",
"effect": "SET_COLOR",
"color": "#FF0000",
"isMuted": false,
"isArchived": false,
"clientName": "Node script",
"createdAt": 1532029505049,
"updatedAt": 1532029505052
},
{
"id": 1282828,
"zoneId": "5,5",
"pid": "DK5QPID",
"userId": 9,
"name": "Your package is on its way",
"message": "Your 5Q is half way to your house",
"effect": "SET_COLOR",
"color": "#00FF00",
"isMuted": false,
"isArchived": false,
"clientName": "Node script",
"createdAt": 1532101242724,
"updatedAt": 1532101288895
}
],
"size": 2,
"sort": "createdAt: ASC",
"hasNextPage": true,
"page": 0,
"totalElements": 53,
"totalPages": 27
}