NAV
bash javascript php python

Introduction

Glance Clock is the world’s first smart clock to display information from all your wearables, smart home devices, web services and third-party applications. We believe that our unique product is the best way to interact with the modern technology.

With Glance Clock you will see only information you need and just when you need it.

Glance Clock integrates with your everyday apps, wearables and services and we would also like to you be a part of our product.

Getting Started

To get started, you need to follow the next steps:

Authentication

Glance Clock developers API uses OAuth 2.0 and API keys to allow access to the API and authenticate your application under specific user’s rights.

After we approve your request described above, you’ll receive following info:

Access Token

To authorize, use this code:

import httplib, urllib, base64

API_GATEWAY = 'https://api.gate.way'
CLIENT_APP_NAME = 'com.yourapp.name'
CLIENT_ID = 'c30c028d636321a0a3aa0f00f596808832ce27f5662d245026978252063fa753'
CLIENT_SECRET = 'f4b7ceff9de68fb46791ba12bdc6d2cc5998c16d59d6e325f685389fd147bf8f'
CLIENT_KEYS = base64.b64encode(CLIENT_ID + ':' + CLIENT_SECRET)

data = urllib.urlencode({
'grant_type': 'password',
'username': CLIENT_APP_NAME,
'password': 'WDFmQm'
})

headers = {
"Authorization": "Basic " + CLIENT_KEYS,
"Content-type": "application/x-www-form-urlencoded"
}

conn = httplib.HTTPConnection(API_GATEWAY)
conn.request("POST", "/v1/oauth/token", data, headers)

response = conn.getresponse()
result = response.read()

conn.close()
<?php

const API_GATEWAY = 'https://api.gate.way';
const CLIENT_APP_NAME = 'com.yourapp.name';
const CLIENT_ID = 'c30c028d636321a0a3aa0f00f596808832ce27f5662d245026978252063fa753';
const CLIENT_SECRET = 'f4b7ceff9de68fb46791ba12bdc6d2cc5998c16d59d6e325f685389fd147bf8f';

$client_keys = base64_encode(CLIENT_ID . ':' . CLIENT_SECRET);

$data = http_build_query([
'grant_type' => 'password',
'username' => CLIENT_APP_NAME,
'password' => 'WDFmQm'
]);

$headers = 'Authorization: Basic ' . $client_keys . '\r\n' .
'Content-Type: application/x-www-form-urlencoded';

$options = [
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => $data
]
];

$context = stream_context_create($options);
$result = file_get_contents(API_GATEWAY . '/v1/oauth/token', false, $context);
const QS = require('querystring');
const HTTP = require('http');

const API_GATEWAY = 'https://api.gate.way';
const CLIENT_APP_NAME = 'com.yourapp.name';
const CLIENT_ID = 'c30c028d636321a0a3aa0f00f596808832ce27f5662d245026978252063fa753';
const CLIENT_SECRET = 'f4b7ceff9de68fb46791ba12bdc6d2cc5998c16d59d6e325f685389fd147bf8f';
const CLIENT_KEYS = new Buffer(CLIENT_ID + ':' + CLIENT_SECRET).toString('base64');

var data = QS.stringify({
grant_type: 'password',
username: CLIENT_APP_NAME,
password: 'WDFmQm'
});

const OPTIONS = {
host: API_GATEWAY,
path: '/v1/oauth/token',
method: 'POST',
headers: {
'Authorization': 'Basic ' + CLIENT_KEYS,
'Content-Type': 'application/x-www-form-urlencoded'
}
};

var req = HTTP.request(OPTIONS, function(res) {
res.setEncoding('utf8');

var result = '';
res.on('data', function (chunk) {
result += chunk;
});

res.on('end', function () {
console.log(result);
});
});

req.write(data);
req.end();
curl -X POST \
-H 'Authorization: Basic YzMwYzAyOGQ2MzYzMjFhMGEzYWEwZjAwZjU5NjgwODgzMmNlMjdmNTY2MmQyNDUwMjY5NzgyNTIwNjNmYTc1MzpmNGI3Y2VmZjlkZTY4ZmI0Njc5MWJhMTJiZGM2ZDJjYzU5OThjMTZkNTlkNmUzMjVmNjg1Mzg5ZmQxNDdiZjhm' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=password&username=com.yourapp.name&password=WDFmQm' \
'https://api.gate.way/v1/oauth/token'

Make sure to replace dummy values with your own.
The above command returns JSON structured like this:

{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"token_type":"bearer",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA"
}

This info is necessary to get Access Token which is associated with a certain user’s account.

To obtain an Access Token you should POST to https://{glanceclock-api-gateway}/v1/oauth/token.

You should include your client credentials in the Authorization header (“Basic “ + client_id:client_secret base64’d), and then grant_type (“password”), username (application name) and password in the request body.

HTTP Request

POST /v1/oauth/token HTTP/1.1
Host: API_GATEWAY
Authorization: Basic YOUR_API_KEYS_IN_BASE64
Content-Type: application/x-www-form-urlencoded

grant_type=password&username=YOUR_APP_NAME&password=USER_UNIQUE_CODE

The password is a unique temporary code which the user is able to find in one of sections of the Glance Clock’s official mobile app.

To authorize your application under some user’s account, you need to ask this user to give you the code, and use it as a “password” in authorization request.

Provided there weren’t any errors, this will return the following:

HTTP Response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache

{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"token_type":"bearer",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA"
`}

After that, you can use Access Token to get access to any other API endpoints. Just pass the correct header with each request:

Authorization: Bearer YOUR_ACCESS_TOKEN

Refresh Token

To authorize, use this code:

import httplib, urllib, base64

API_GATEWAY = 'https://api.gate.way'
REFRESH_TOKEN = 'tGzv3JOkF0XG5Qx2TlKWIA'
CLIENT_ID = 'c30c028d636321a0a3aa0f00f596808832ce27f5662d245026978252063fa753'
CLIENT_SECRET = 'f4b7ceff9de68fb46791ba12bdc6d2cc5998c16d59d6e325f685389fd147bf8f'
CLIENT_KEYS = base64.b64encode(CLIENT_ID + ':' + CLIENT_SECRET)

data = urllib.urlencode({
'grant_type': 'refresh_token',
'refresh_token': REFRESH_TOKEN
})

headers = {
"Authorization": "Basic " + CLIENT_KEYS,
"Content-type": "application/x-www-form-urlencoded"
}

conn = httplib.HTTPConnection(API_GATEWAY)
conn.request("POST", "/v1/oauth/token", data, headers)

response = conn.getresponse()
result = response.read()

conn.close()
<?php

const API_GATEWAY = 'https://api.gate.way';
const REFRESH_TOKEN = 'tGzv3JOkF0XG5Qx2TlKWIA';
const CLIENT_ID = 'c30c028d636321a0a3aa0f00f596808832ce27f5662d245026978252063fa753';
const CLIENT_SECRET = 'f4b7ceff9de68fb46791ba12bdc6d2cc5998c16d59d6e325f685389fd147bf8f';

$client_keys = base64_encode(CLIENT_ID . ':' . CLIENT_SECRET);

$data = http_build_query([
'grant_type' => 'refresh_token',
'refresh_token' => REFRESH_TOKEN
]);

$headers = 'Authorization: Basic ' . $client_keys . '\r\n' .
'Content-Type: application/x-www-form-urlencoded';

$options = [
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => $data
]
];

$context = stream_context_create($options);
$result = file_get_contents(API_GATEWAY . '/v1/oauth/token', false, $context);
const QS = require('querystring');
const HTTP = require('http');

const API_GATEWAY = 'https://api.gate.way';
const REFRESH_TOKEN = 'tGzv3JOkF0XG5Qx2TlKWIA';
const CLIENT_ID = 'c30c028d636321a0a3aa0f00f596808832ce27f5662d245026978252063fa753';
const CLIENT_SECRET = 'f4b7ceff9de68fb46791ba12bdc6d2cc5998c16d59d6e325f685389fd147bf8f';
const CLIENT_KEYS = new Buffer(CLIENT_ID + ':' + CLIENT_SECRET).toString('base64');

var data = QS.stringify({
grant_type: 'refresh_token',
refresh_token: REFRESH_TOKEN
});

const OPTIONS = {
host: API_GATEWAY,
path: '/v1/oauth/token',
method: 'POST',
headers: {
'Authorization': 'Basic ' + CLIENT_KEYS,
'Content-Type': 'application/x-www-form-urlencoded'
}
};

var req = HTTP.request(OPTIONS, function(res) {
res.setEncoding('utf8');

var result = '';
res.on('data', function (chunk) {
result += chunk;
});

res.on('end', function () {
console.log(result);
});
});

req.write(data);
req.end();
curl -X POST \
-H 'Authorization: Basic YzMwYzAyOGQ2MzYzMjFhMGEzYWEwZjAwZjU5NjgwODgzMmNlMjdmNTY2MmQyNDUwMjY5NzgyNTIwNjNmYTc1MzpmNGI3Y2VmZjlkZTY4ZmI0Njc5MWJhMTJiZGM2ZDJjYzU5OThjMTZkNTlkNmUzMjVmNjg1Mzg5ZmQxNDdiZjhm' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=refresh_token&refresh_token=tGzv3JOkF0XG5Qx2TlKWIA' \
'https://api.gate.way/v1/oauth/token'

Make sure to replace dummy values with your own.
The above command returns JSON structured like this:

{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"token_type":"bearer",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA"
}

Also, you can use Refresh Token to refresh expired Access Token without is necessary to disturb the user:

HTTP Request

POST /v1/oauth/token HTTP/1.1
Host: API_GATEWAY
Authorization: Basic YOUR_API_KEYS_IN_BASE64
Content-Type: application/x-www-form-urlencoded

grant_type=refresh_token&refresh_token=REFRESH_TOKEN

You’ll receive a new relevant Access Token.

Drawing primitives

This section describes a high-level patterns to draw your data on Glance Clock. This list of patterns right now is short, but will be extended at development of UI/UX solutions for Glance Clock.

Segments

To draw segments, use this code:

import httplib, json

API_GATEWAY = 'https://api.gate.way'
ACCESS_TOKEN = '2YotnFZFEjr1zCsicMWpAA'

data = json.dumps([{
'start': 1,
'length': 3,
'color': '#3384F4',
'text': 'Hello World'
}])

headers = {
"Authorization": "Bearer " + ACCESS_TOKEN,
"Content-type": "application/json"
}

conn = httplib.HTTPConnection(API_GATEWAY)
conn.request("POST", "/v1/draw/segments", data, headers)

response = conn.getresponse()
result = response.read()

conn.close()
<?php

const API_GATEWAY = 'https://api.gate.way';
const ACCESS_TOKEN = '2YotnFZFEjr1zCsicMWpAA';

$data = json_encode([[
'start' => 1,
'length' => 3,
'color' => '#3384F4',
'text' => 'Hello World'
]]);

$headers = 'Authorization: Bearer ' . ACCESS_TOKEN . '\r\n' .
'Content-Type: application/json';

$options = [
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => $data
]
];

$context = stream_context_create($options);
$result = file_get_contents(API_GATEWAY . '/v1/draw/segments', false, $context);
const HTTP = require('http');

const API_GATEWAY = 'https://api.gate.way';
const ACCESS_TOKEN = '2YotnFZFEjr1zCsicMWpAA';

var data = JSON.stringify([{
start: 1,
length: 3,
color: '#3384F4',
text: 'Hello World'
}]);

const OPTIONS = {
host: API_GATEWAY,
path: '/v1/draw/segments',
method: 'POST',
headers: {
'Authorization': 'Bearer ' + ACCESS_TOKEN,
'Content-Type': 'application/json'
}
};

var req = HTTP.request(OPTIONS);

req.write(data);
req.end();
curl -X POST \
-H 'Authorization: Bearer 2YotnFZFEjr1zCsicMWpAA' \
-H 'Content-Type: application/json' \
-d '[{"start":"1","length":"3","color":"#3384F4","text":"Hello World"}]' \
'https://api.gate.way/v1/draw/segments'

Make sure to replace dummy values with your own.

This primitive you may see using Google Calendar or Apple Calendar on your Glance Clock.

HTTP Request

POST /v1/draw/segments HTTP/1.1
Host: API_GATEWAY
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

[{
"start": "...",
"length": "...",
"color": "...",
"text": "..."
}, ...]

JSON object properties

Parameter Values Default Description
start 1-12 1 Start position of each segment. Can be a floating-point number, not only integer, to display parts of hour.
length 1-12 1 Length of each segment. Can be a floating-point number, not only integer, to display parts of hour.
text string “” Text string.
color hex random (Optional) Color of each segment.

Important feature in spite of the fact that you can choose any color as parameter, API automatically will convert your color to nearest color in colors palette supported by Glance Clock. This feature is applied to any color parameters of API.

Developer’s API is also automatically will redistribute visual positioning of segments and their thickness depending on crossings of these segments’s “start” and “length” values. But don’t forget that only 4 lines is available.

Here and everywhere below, text string will be scrollable if will needed. We also calculate speed of scrolling regarding text string length.

Provided there weren’t any errors, this will return the following:

HTTP Response

HTTP/1.1 202 Accepted
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache

Here and everywhere below, response from server doesn’t contain any data. That means your content is accepted and will be transferred to the device.

Notice

To draw notice, use this code:

import httplib, json

API_GATEWAY = 'https://api.gate.way'
ACCESS_TOKEN = '2YotnFZFEjr1zCsicMWpAA'

data = json.dumps({
'color': '#3384F4',
'animation': 'Pulse'
'text': 'Hello World'
})

headers = {
"Authorization": "Bearer " + ACCESS_TOKEN,
"Content-type": "application/json"
}

conn = httplib.HTTPConnection(API_GATEWAY)
conn.request("POST", "/v1/draw/notice", data, headers)

response = conn.getresponse()
result = response.read()

conn.close()
<?php

const API_GATEWAY = 'https://api.gate.way';
const ACCESS_TOKEN = '2YotnFZFEjr1zCsicMWpAA';

$data = json_encode([
'color': '#3384F4',
'animation': 'Pulse'
'text': 'Hello World'
]);

$headers = 'Authorization: Bearer ' . ACCESS_TOKEN . '\r\n' .
'Content-Type: application/json';

$options = [
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => $data
]
];

$context = stream_context_create($options);
$result = file_get_contents(API_GATEWAY . '/v1/draw/notice', false, $context);
const HTTP = require('http');

const API_GATEWAY = 'https://api.gate.way';
const ACCESS_TOKEN = '2YotnFZFEjr1zCsicMWpAA';

var data = JSON.stringify({
'color': '#3384F4',
'animation': 'Pulse'
'text': 'Hello World'
});

const OPTIONS = {
host: API_GATEWAY,
path: '/v1/draw/notice',
method: 'POST',
headers: {
'Authorization': 'Bearer ' + ACCESS_TOKEN,
'Content-Type': 'application/json'
}
};

var req = HTTP.request(OPTIONS);

req.write(data);
req.end();
curl -X POST \
-H 'Authorization: Bearer 2YotnFZFEjr1zCsicMWpAA' \
-H 'Content-Type: application/json' \
-d '{"color":"#3384F4","animation":"Pulse","text":"Hello World"}' \
'https://api.gate.way/v1/draw/notice'

Make sure to replace dummy values with your own.

This primitive you may see using Weather or Todoist service on your Glance Clock.

HTTP Request

POST /v1/draw/notice HTTP/1.1
Host: API_GATEWAY
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

{
"text": "...",
"sound": "...",
"animation": "...",
"color": "..."
}

JSON object properties

Parameter Values Default Description
text string “” Text string.
sound Beep, Notify, Call, Uber, Alarm None (Optional) Name of one of pre-defined sounds.
animation Pulse, Wave, Fire, Wheel, Flower, Fan, Sun, Thunderstorm, Cloud None (Optional) Name of one of pre-defined animations.
color hex random (Optional) Color of animation.

SDKs

Terms of Use

Errors

Developer’s API uses the following error codes:

Error Code Meaning
400 Bad Request – Your request has bad parameters.
401 Unauthorized – Your Access Token or API keys are wrong.
403 Forbidden – The endpoint requested out of your scope.
404 Not Found – The specified endpoint could not be found.
405 Method Not Allowed – You tried to access to endpoint with an invalid method.
406 Not Acceptable – You requested a format that isn’t json.
429 Too Many Requests – You’re requesting too many times! Slow down!
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarily offline for maintenance. Please try again later.