OVERVIEW
About this guide
This guide provides an overview of the RTLS Server API, including initial setup and reference material for REST and streaming data APIs.
Audience
This guide is for software developers to create their own applications using Redpoint APIs. This guide assumes you know how to create applications with HTTP, REST-style APIs, and WebSockets.
Redpoint Partner Branding Guidelines
Redpoint Positioning Corp. requires all partner companies to display the ‘Positioned by Redpoint’ logo:
- On your software UI if you access the Redpoint server API
- On the outside of your tag if you use the Redpoint RTLS module
For questions about partner branding, or to obtain the logo, please contact support@redpointpositioning.com.
Introduction
The RTLS server allows you to access information for the Redpoint infrastructure and nodes on the network. The server includes both real-time and historic data.
The RTLS Server API can be divided into two categories:
- Request-Reply, managed by HTTP REST APIs.
- Streaming data, managed by a WebSocket API.
About REST APIs
Representational State Transfer (REST) calls are an industry standard interface that allow a user to get and update data based on various parameters. This interface is used to manage the system, but is not for steaming real-time data, which is managed by the WebSocket API.
About Streaming WebSocket APIs
For low-latency real-time data, the RTLS server provides a publication/subscription mechanism through a WebSocket API. This mechanism pushes real-time data to the applications.
Terminology
The following is a list of the terminology used in Redpoint RTLS platform. We assume the reader of this document is familiar with the general configuration and operation of the RTLS platform.
- Anchor - A stationary node at a fixed location, also called a fixed node. The WIN Anchors API is used to manage anchors.
- Anonymous node - A node that has not been configured by the network.
- Area - A section of a site that has its own floorplan, for example, each floor of a multi-story building can be defined as an area. The Sublocation API is used to manage areas.
- Bridge - An anchor that includes a LAN interface that bridges the Redpoint UWB network and a local area network. The WIN Anchors API is used to manage anchors.
- Buffer - Formerly dynamic zone or circular zone. A circular geofence with a defined radius. It is connected to a specific trackable and moves with it. The Zones API is used to manage buffers.
- Group - A label used to identify specified trackable objects that share characteristics. The Groups API is used to manage groups.
- HTTP (Hypertext Transfer Protocol) - The primary protocol that enables data transfer over the World Wide Web.
- LS (Location Service) - A tool used to set schedules on the Redpoint network.
- Multi-tiered buffer - A buffer that has escalating levels of severity defined by the distance from the connected trackable. The Zones API is used to manage multi-tiered buffers.
- Node - A Redpoint radio device including anchors, bridges, tags, badges, and so on. The Nodes API is used to manage nodes.
- REST (Representational State Transfer) - An industry standard interface that allow a user to get and update data based on various parameters.
- Sensor - A third-party device attached to the sensor interface of a node. A sensor should not be confused with a "sensor node," which is a Redpoint radio device.
- Sensor node - A node that is stationary but is not part of the WIN, because it does not route data from other devices in the network.
- Site - A space that has RTLS coverage, for example, a building or a campus. A server might service one or more sites. The Location API is used to manage sites.
- Trackable - An entity, such as a person or asset, to be tracked. Trackables should be associated with the MAC address of a tracking device to be tracked. The Trackable Objects API is used to manage trackables.
- WebSocket - A publisher-subscriber mechanism to allow the HTTP client to receive streaming data from the server. The Websocket API is used to manage the websocket.
- WIN (Wireless Infrastructure Network) - A network of anchors that are connected wirelessly. A WIN provides location services and data communication.
- Zone - A geofence assigned to a particular place on an area. A zone can function as a safety zone (keep-in or keep-out), which triggers alarms, or an information zone. The Zones API is used to manage zones.
Getting started
This section includes information on how to:
- Access the Redpoint APIs.
- Find sample code
- Set up the Redpoint environment
- Make a request
- Include common headers
- View common status and error codes.
To access Redpoint APIs
All RPP APIs can be accessed from the delivered Redpoint server.
To locate sample code
Sample requests and responses are included in the individual APIs as examples.
To set up the Redpoint environment
All Redpoint APIs require a standard set of headers. Set up authentication to obtain these headers. After the headers are obtained, use the REST APIs to retrieve and update data, and use the WebSocket API to subscribe to streaming data.
To make a request
For REST APIs, make requests in the form:
GET api/floorplans/{uid}
In this case, the specified UID narrows the GET request to a single floorplan. Additional parameters in the body of the request are available for some methods in order to narrow return results further.
To include common headers
The following example shows common headers that should be included in all requests:
Content-type: application/json X-User-Token: Drv3yU7PdyqUMtr89erZ X-User-Email: admin@example.com
The user token and email can be obtained in Authentication Setup.
Error and status codes
The APIs all return error and status codes. All APIs return code 200 on success, but the error codes vary depending on the type of problem encountered. Rest Client shall expect error code to be returned even the request it self is valid for reasons as "Server Locked" (423), "Too many requests" (429). In this case server will return Retry-After: 10 header where the number value is amount of seconds to wait before retrying request.
| Code | Type | Description |
|---|---|---|
| 20x | Status | Indicates success. The code might be 200, 201, 202, or similar. |
| 4xx | Error | Indicates a problem with the request. The code might be 400, 401, 402, 422, or similar. |
Authentication setup
For more information, see the Auth API.
Whenever accessing the REST services, the REST client must provide authentication information in form of REST server email of the user as well as the access token for the user.
This section includes information about:
- Obtaining authentication tokens
- Using authentication tokens
- Validating an existing authentication token
- Expiring an existing authentication token
Obtain an authentication token
POST api/auth/log_in
The request must be of application type JSON, that is, the submitted headers must include the header:
Content-type: application/json
For more information, see the Auth API.
Request fields
| Field | Required/Optional | Type | Description |
|---|---|---|---|
| required | string | The email address of the user commissioned on the RTLS server. | |
| password | required | string | The password of the user associated with the account on the RTLS server. |
Response fields
| Field | Description |
|---|---|
| success | Whether the request to log in was successful. |
| data | A JSON object with information about the current user. |
| data.email | The email used to log in. |
| data.token | The token generated by the request. |
| data.company | The company associated with the current user. |
| data.company.id | The identifier of the company in the context of the server. |
| data.company.name | The company name. |
| data.company.taggings_counts | Reserved field. |
| data.company.user_params | A JSON object with user-defined parameters. |
| data.company.uid | The unique identifier of the current user. |
| data.company.scope | Reserved field. |
| data.company.role_uid | Reserved field. |
| data.company.role | Reserved object. |
| isSuperAdmin | Whether the user is a super administrator user. For more information about user types and access levels, see SiteWise Administrator Guide. |
| isSystemUser | Whether the user is a project user. For more information about user types and access levels, see SiteWise Administrator Guide. |
Request example
The body of the JSON object must include attributes email and password including account information on the REST server. For example:
{
"email": "user@example.com",
"password": "password"
}
Response example
If the provided email and password are validated successfully, it returns with status code 200. The below is an example of a successful validation, which returns an authentication token on line 5.
{
"success": true,
"data": {
"email": "user@example.com",
"token": "Drv3yU7PdyqUMtr89erZ",
"company": {
"id": 15,
"name": "Company name",
"taggings_count": 1,
"user_params": {
"color": "#ff0000",
"role": "Subcontractor",
"phone": "22131",
"website": "wwww"
},
"uid": "AA_Dn4M4Tg64gqE6N91RO1",
"scope": "Y",
"role_uid": "Hyf5F8KqEeagPwhgboMCKw",
"role": {
"id": 3,
"name": "Subcontractor",
"uid": "Hyf5F8KqEeagPwhgboMCKw",
"display_name": "Company"
}
},
"isSuperAdmin": false,
"isSystemUser": true
}
}
If the authentication was unsuccessful, the following JSON object is returned with status code 401:
{
"success": false,
"error": "Unable to log in. Check your email address and your password."
}
Use an authentication token
After the user has logged in and obtained a token, all the subsequent requests towards RTLS REST must include the following headers:
| Header Name | Example Value | Description |
|---|---|---|
| X-User-Email | admin@example.com | The email of the user performing HTTP requests to the API. |
| X-User-Token | Drv3yU7PdyqUMtr89erZ | The authentication token in the response of obtain an authentication token. |
The user must obtain an authentication token by using POST api/auth/log_in. If the token is invalid, the email is already used, or if the X-User-Token or X-User-Email are missing, the system returns a JSON object and unauthorized status of 401 for any API request:
{
"success": false,
"error": "You need to sign in or sign up before continuing."
}
If the access request was properly authenticated, the system returns an OK status of 200 and the desired object.
The below example is a successful response for a request to GET /api/nodes/:
{
"nodes": [
{
"name": "00000000001C",
"mac_address": "00000000001C",
"parent_mac_address": "00000000001b",
"bridge_mac_address": "00000000001a",
"sw_version": {
"sw_str": null,
"git": "95DD2D30"
},
"hw_info": null,
"last_heard": "2017-04-07T13:18:19.000Z",
"announce": null,
"node_type": "TO",
"battery_status": null,
"uwb_trx_config": null,
"node_status": null,
"periferial_info": null,
"created_at": "2017-02-16T08:25:06.000Z",
"updated_at": "2017-03-16T09:19:43.000Z",
"uid": "ikvKczuhTbGfuM6pydQGPw",
"project_uid": null,
"current_system_timestamp": "2017-04-07T13:18:30.802Z"
}
]
}
Validate an existing authentication token
GET api/auth/validate_token
Occasionally, you might need to check if the token you are using is valid. To check your token, issue a GET to /api/auth/validate_token. A successful request returns a JSON object with status of 200:
{
"success": true,
"data": {
"email": "admin@example.com",
"token": "Drv3yU7PdyqUMtr89erZ"
}
}
Failure to authenticate with an existing token results in failure object and a forbidden status of 403:
{
"success": false,
"error": "Unable to authenticate admin@example.com"
}
If the token validation fails, log in with your email address and password to obtain a new token.
Refresh an authentication token
To expire an existing token and obtain a new one, issue a GET request to /api/auth/refresh_token using the following headers:
| Header Name | Example Value | Description |
|---|---|---|
| X-User-Email | admin@example.com | Email of the user performing HTTP requests to the API. |
| X-User-Token | Drv3yU7PdyqUMtr89erZ | Token allowing the user access to the API. |
On success, a JSON object returned with status 200. The response also includes a new, updated token.
{
"success": true,
"data": {
"email": "admin@example.com",
"token": "Drv3yU7PdyqUMtr89erZ"
}
}
A failure to authenticate with an existing token returns a failure object and a forbidden status of 403:
{
"success": false,
"error": "Unable to authenticate admin@example.com"
}
API Types
API types include:
- Server APIs, which are based on the REST style of calls.
- Streaming data APIs, which are based on the WebSocket communications protocol.
Server APIs
Request-Reply
The server APIs use a request-reply model to transfer data using REST calls.
About REST calls
Representational State Transfer (REST) calls are an industry standard interface that allow a user to communicate with the RTLS server to retrieve and set various parameters to operate of the RTLS network. The application must initiate a call. The REST interface is the primary interface to access and manage the system and device information.
REST calls can only be used for accessing non-real-time data. Though the application can poll the server via REST calls for the latest information of a tag, such as the sites, alarms, and other real-time information, they are not used as the primary way to access real-time data. To access streaming, real-time data, Redpoint applications use a WebSocket API.
The REST interface exposes the Wireless Infrastructure Network (WIN) information to the outside world using well-defined queries.
Types of functionality
Rest calls include functionality for:
- Authentication.
- Project management.
- Infrastructure for the building, including the site and floorplans.
- RTLS network configuration.
- Trackable object management.
- Zone management, including safety and informational alerts.
- Alarm management.
- Reporting management.
Streaming data API
WebSockets
All streaming data can be managed by the WebSocket API, which uses the lightweight stateless remote procedure call (RPC) protocol, JSON-RPC 2.0, to provide interfaces to manage subscriptions and receive streaming data.
Real-time streaming data
The RPP Websocket API uses a publisher-subscriber mechanism to allow the HTTP client to receive streaming data from the server. By subscribing to channels, you can receive data for:
- Real-time positioning
- System notifications
- Alarms
Real-time positioning data
Subscribe to the pos channel to receive real-time positioning data for the position of trackables.
System notifications
Subscribe to the notify channel to receive real-time updates on application events, such as creating or modifying a zone, adding an anchor, and so on.
Alarms
Subscribe to the alarm channel to receive information about zone and buffer violations and call button alerts.
Disclaimer
Redpoint Positioning, Corp. (The Company) makes no warranties for the use of its products, other than those expressly contained in the Company’s warranty agreement. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein. No licenses to patents or other intellectual property of Redpoint Positioning are granted by the Company in connection with the sale of Redpoint Positioning products, expressly or by implication. No part of this material may be reproduced or transmitted in any form or by any means or used to make any derivative work without express written consent from the copyright holders.