The REST interface allows retrieval of data from systems which are uploading to the RACE RESULT servers, this includes RACE RESULT decoders which are uploading via TCP and Track Boxes. The REST API allows for commands to be sent to decoders for remote control.
For communication with the REST API you will need an API Keys for the Customer ID you wish to access.
Endpoint URL
All commands for the REST API interface should point to:
https://rest.devices.raceresult.com
You should ensure to include Connection: close in all calls to ensure the connections are not left open which may cause our servers to activate security protocols which will block your IP address.
Authorization
In order to access the REST API you will need to authenticate using an API key for the Customer ID which will generate an authorization token.
API Key
API keys can be generated by each user within the RACE RESULT customer account page. API keys are hidden by default but can be displayed & copied easily.
Each API key is unique and tied to the specific customer ID, an API key is valid until it is deleted by the user.
Generating Access Token
An access token is generated using the /token command.
This command uses a POST request with the API key included in the request HEADER as follows:
apikey | APIKeyHere |
The command will return the Access Token
Using the Access Token
The access token should be included in the Headers for each subsequent command request as Bearer Authorization.
Your header should include the access token in the following format
Authorization | Bearer AccessTokenHere |
Note that each token is only valid for a fixed period of time, after which point it should be regenerated, by default tokens are valid for 7200 seconds (2 hours).
In normal practice, applicationss will use the same token until a 401 error status is received, at which point you will attempt to generate a new token and retry the failed request.
Commands
Commands available through the rest interface include:
- Listing available devices and statuses
- Listing available files from systems
- Retrieving passings
- Send decoder commands (Remote Control)
- Check REST interface status
Commands are sent via either GET or POST requests (according to the specific request) and will use the token generated during authorization.
Response data is returned in JSON format, according to the command sent in specified data Models.
URL Parameters
{customerID} - The ID of the customer which should be queried (Integer)
{deviceID} - The ID of the device which should be queried (String)
{FileNo} - The file number to be queried (Integer)
HTTP Status Codes
200 - OK
400 - Bad Request
500 - Internal Server Error
List Devices
GET .../customers/{customerID}/devices
Returns all devices with their status for the given customer
Query Parameters
deviceIDs (String) - Comma separated list of Device IDs to query
connected (bool) - If set to true response is limited to only devices which are currently reported as online
Response Format
{
"Devices": array[Device Status]
}
Get Device Status
GET .../customers/{customerID}/devices/{deviceID}
Returns the status of the specified device
Response Format
List Files
GET .../customers/{customerID}/files
Returns all files belonging to the given customer
Query Parameters
deviceIDs (String) - Comma separated list of Device IDs to query
Response Format
{
"Files": array[ Device File Metadata ]
}
List Device Files
GET .../customers/{customerID}/devices/{deviceID}/files
Returns all files of the specified device
Query Parameters
files (string) - Comma separated list of file numbers (integer) to be queried. Invalid file numbers will be ignored.
latest (bool) - If true returns only the latest file. See alternate response below.
Response Format
{
"Files": array[ Device File Metadata ]
}
Alternative Response Format
{
"File": Device File Metadata
}
Get File Metadata
GET .../customers/{customerID}/devices/{deviceID}/files/{fileNo}
Returns the metadata of the passing file from the specified device / file number.
Response Format
Get Detections (File)
GET .../customers/{customerID}/devices/{deviceID}/files/{fileNo}/detections
Returns the content of the passings file with the given device ID / file number
Query Parameters
fromDetection (integer) - The minimum passing/trackping number to start with (default: 1)
amount (integer) - The amount of detections to send from the file, if there are less detections available then the max available will be sent
download (integer) - Set 1 to download as a file (.txt format)
Response Format
array[ Detection Data ]
Get Detections (Multi)
GET .../customers/{customerID}/devices/{deviceID}/detections
Returns all detections for the given device ID
Query Parameters
fromFile (integer) - The minimum file number to be queried (default: 1)
fromDetection (integer) - The minimum passing/trackping number to start with (default: 1)
amount (integer) - The amount of detections to send from the file, if there are less detections available then the max available will be sent
download (integer) - Set 1 to download as a file (.txt format)
Response Format
array[ Detection Data ]
Send Decoder Command
POST .../customers/{customerID}/devices/{deviceID}/cmd
Sends a command to a device and returns the result
Query Parameters
command (string) - The command to be sent to the device
Response Format
{
"Response": String
}
Service Health
GET .../health
Returns OK (HTTP 200) is the service is up and running
Deprecated
The following commands have been deprecated and should not be used. They will continue to work for existing implementations until otherwise notified.
Models
In the REST API interface all responses are returned in JSON format, data fields are returned in alphabetical order.
Access Token
Contains an access token. The access token authenticates the customer in all further calls. An access token expires after a few hours.
Header | Format | Description |
access_token | String | The newly generated access token |
expires_in | Integer | Expires in X seconds from the time of this requiest |
token_type | String | To be used in the Authorization Header: token_type access_token |
Device Status
A status holder that can contain either a status for either an Ubidium System, Decoder or Track Box. Note that the format of response may differ according to the device type.
Values - Ubidium
Header | Format | Description |
ActiveExternal | Ubidium Active | |
ActiveInternal | Ubidium Active | |
Customer | Integer | |
ConnStatus | Integer | enum[Disconnected, Connected, Bad Connection] |
Data | Ubidium Data | |
Passive | Ubidium Passive | |
Position | Position | |
Power | Ubidium Power | |
Settings | Ubidium Settings | |
System | Ubidium System | |
Time | Ubidium Time |
Values - Decoder / TrackBox
Header | Format | Description |
Customer | Integer | |
DeviceID | String | |
Received | String | DateTime |
DeviceName | String | |
FileNo | Integer | |
BatteryCharge | Integer | |
Temperature | Number | Float |
RecordsCount | Integer | |
IsRunTime | Bool | |
RealTime | String | DateTime |
RealTimeAtRequest | String | DateTime |
RunTime | Number | Double Only filled if RealTimeAtRequest is before 1000-01-01, indicating a zero start event. |
RunTimeAtRequest | Number |
Double Only filled if RealTimeAtRequest is before 1000-01-01, indicating a zero start event. |
UTCOffset | Integer | |
TimeZoneName | String | |
Position | Position | |
Connected | Bool | |
DeviceType | String | enum[Decoder, TrackBox] |
DecoderStatus | Decoder Status | |
TrackboxStatus | Track Box Status |
Ubidium Status
Active
Header | Format | Description |
Boxes | array[ Beacon ] | |
Channel | Integer | |
Connected | Bool | |
LoopID | Integer | |
LoopStatus | Integer | |
LoopPower | Integer |
Battery
Header | Format | Description |
Installed | Bool | |
Level | Integer | |
Remaining | Integer | |
State | Integer |
Data
Header | Format | Description |
FileNumber | Integer | |
PassingID | Integer | |
PassingNo | Integer |
Passive
Header | Format | Description |
Battery1 | Ubidium Battery |
|
Battery2 | Ubidium Battery |
Power
Header | Format | Description |
Boxes | array[ Beacon ] | |
Channel | Integer | |
Connected | Bool | |
LoopID | Integer | |
LoopStatus | Integer | |
LoopPower | Integer |
Settings
Header | Format | Description |
DeadTime | Integer | |
ReactionTime | Integer |
System
Header | Format | Description |
DeviceID | String | |
DeviceName | String | |
Firmware | String | |
Temperature | Integer |
Time
Header | Format | Description |
DeviceTimeAtRequest | String | DateTime |
Offset | Integer | |
Received | String | DateTime |
Time | String | DateTime |
Decoder Status
Decoder status values
Values
Header | Format | Description |
Protocol | Number | Float |
Firmware | String | |
Antennas | String | 8 characters 0 or 1 to represent which antenna ports are connected |
HasPower | Bool | |
Ext12Volt | Number |
Float Voltage on the 12V power input |
IsInTImingMode | Bool | |
ReaderIsHealthy | Bool | |
TimeIsRunning | Bool | |
ReaderTemperature | Number |
Float Temperature in °C |
DeadTime | Integer | |
ReactionTime | Integer | |
Notification | String | |
UHFFrequency | Integer | |
TimeSource | Integer | |
AutomaticStandbyEnabled | Bool | |
IsInStandby | Bool | |
ErrorFlags | Integer | |
ActiveExtension | Beacon | |
ActiveBoxes | array[ Beacon ] |
Track Box Status
Track Box Status values
Values
Header | Format | Description |
Protocol | Integer | |
Channel | Integer | 2.4Ghz Channel Index (0...7) |
MemoryLeft | Integer | |
Noise | Integer | |
Cell | String | |
LAC | String | |
Satellites | Integer | |
Session | String | |
BoxVariant | String | enum[ ATrack, PTrack ] |
PowerStatus | String | enum[ BATTERY, POWER, SUNNY, SHADY, ERROR ] |
ReaderStatus | String | enum[ ON, NOSYNC, SYNC, MULT, OFF, WARN, ERROR ] |
NetPLMN | Integer | |
NetProvider | String | |
NetSignal | Integer |
Position
GPS position location of the system at the time of upload
Header | Format | Description |
Altitude | Integer | |
Flag | String |
Additional information about the systems position / movement at the time of upload.
|
Latitude | Number | Double |
Longitude | Number | Double |
Beacon
Active Box beacon information
Header | Format | Description |
BeaconIndex | Integer | |
BeaconLQI | Integer |
|
BeaconRSSI | Integer | |
BeaconTimestamp | String | |
Channel | Integer | |
ChannelSwitchingMode | String | |
Connected | Bool | |
ID | Integer | |
LoopID | Integer | |
LoopPower | Integer | |
LoopStatus | Integer | |
Mode | Integer | |
NoiseAvg | Integer | |
NoisePeak | Integer | |
PowerConn | Integer | |
PowerStatus | Integer | |
SinceLastSeen | Integer | Duration as nanosecond count |
TransLQI | Integer | |
TransRSSI | Integer |
Device File Metadata
Metadata of the passings / trackping file
Header | Format | Description |
Count | Integer | |
Created | String |
DateTime |
Customer | Integer | |
DeviceID | String | |
FileNo | Integer | |
FilePos | Position |
Detection Data
Detection data represents an abstract class which may return one of the following according to the request:
Ubidium Detection
Ubidium Detection Data
Header | Format | Description | |
act_data | Active Passing Data |
Active passing data |
|
hits | Integer | Hits count | |
id | Integer | Internal ID of the passing | |
internal | String | Internally calculated code | |
loc | Passing Location | Location of the device at the time of passing (Omitted if empty) |
|
no | Passing Number | Passing file reference | |
rssi | Integer | RSSI Value of active passing | |
src | Passing Source | Device data of passing | |
time | String |
DateTime Full DateTime of the passing |
|
time_offset | Integer | Time zone offset of device at time of passing | |
transp | Transponder Data |
Transponder data of passing |
Active Passing Data
Header | Format | Description | |
channel | Integer | Active passing channel | |
flags | Integer | Status / Warning Flags (Omitted if empty) |
|
loop_id | Integer | Active passing Loop ID | |
loop_only | Bool | True if the passing was generated in store mode (Omitted if empty or false) |
Passing Location
Header | Format | Description | |
alt | Number | Float Altitude |
|
lat | Number |
Float Latitude |
|
long | Number | Float Longitude |
Passing Number
Header | Format | Description | |
file | Integer | Passing file number | |
no | Integer | Passing number within the file |
Passing Source
Header | Format | Description | |
customer | Integer | Customer ID passing was retrieved from | |
device_id | String | Device ID | |
device_name | String | Device name (Omitted if empty) |
|
input | String | Name of the (sub) device that generated the passing |
Transponder Data
Header | Format | Description | |
active | Active Transponder Data | Additional active transponder data (Omitted if empty) |
|
id | String | Transponder ID | |
passive | Passive Transponder Data | Additional passive transponder data (Omitted if empty) |
Active Transponder Data
Header | Format | Description | |
bat | Integer | Transponder battery data at time of passing Divide by 10 to retrieve true battery Voltage |
|
temp | Integer | Transponder temperature at time of passing (°C) |
|
wuc | Integer | Transponder wake-up-count |
Passive Transponder Data
Header | Format | Description | |
order_id | Integer | The OrderID for the transponder |
Decoder Passing
A decoder passing record
Header | Format | Description | |
Battery | Number |
Float Active Transponder battery voltage (v) |
|
Channel | Integer | Active Channel on which the passing was recorded | |
Code | String | Transponder code or number | |
Customer | Integer | Customer ID the passing was uploaded to | |
DeviceID | String | ID of the device which recorded the passing | |
DeviceName | String | Name of the device which recorded the passing, as of the time of upload | |
FileNo | Integer | File number the passing is saved to | |
Hits | Integer | Hits count | |
InternalActiveData* | Integer | Status Flags for Active passings | |
InternalData | String | Internally calculated code | |
IsActive | Bool | True if generated from an Active Transponder | |
LoopID | Integer | Active Loop ID on which the passing was recorded | |
LoopOnly | Bool | Is true if the passing was recorded in Store mode | |
MaxRSSIAntenna | Integer | The passive antenna port which recorded the passing | |
OrderID | Integer | The OrderID for the transponder | |
Position | Position | ||
PassingNo | Integer | PassingID within the file | |
RSSI | Integer | RSSI Value of active passing | |
Temp | Integer | Active Transponder recorded temperature | |
IsRunTime | Bool | Is true if the RealTime date is before 1000-01-01, indicating a zero start event (Not using GPS time or synced computer time) | |
RealTime | String |
DateTime Full DateTime of the passing |
|
RunTime | Number |
Double The run time as a value in seconds, only filled if RealTime is before the date 1000-01-01, indicating a zero start event. |
|
UTCOffset | Integer | System UTC Offset at the time of the passing | |
WUC | Integer | Transponder wake-up-count |
Trackping
A Trackping record
Header | Format | Description | |
TrackpingNo | Integer | Trackping ID within the file | |
Customer | Integer | Customer ID the trackping was uploaded to | |
DeviceID | String | Device ID which recorded the Trackping | |
FileNo | Integer | File number the Trackping is saved to | |
BoxType | String | enum[ ATrack, PTrack ] | |
DeviceName | String | Name of the device which recorded the Trackping as of the time of recording | |
Code | String | Transponder code or number | |
Time | String |
DateTime Full DateTime of the Trackping |
|
BoxTime | String |
DateTime Timestamp of the device when sending the Trackping |
|
Received | String |
DateTime Timestamp of the server when the Trackping was received |
|
Cell | String | Mobile network cell | |
Hits | Integer | Hits count | |
LAC | String | Location Area Code | |
MinRSSI | Integer | Minimal RSSI value of Trackping | |
MinTime | String |
DateTime Timestamp the minimal RSSI was recorded |
|
OrderID | Integer | Order ID of the transponder | |
PeakIndex | Integer | Index of the highest RSSI value | |
RSSI | Integer | RSSI value of Trackping | |
Position | Position | Position of the device at the time the Trackping was recorded | |
BoxPosition | Position | Position of the device at the time the Trackping was uploaded |
Basic Example
This basic example looks at the first steps in using the REST interface, it looks at how to:
- Retrieve an access token
- Check which systems are online for the customer
- Check System Status
- Retrieve the passings from a specified file
- Retrieve all passings from a specified starting point
This example was achieved using Postman a useful tool for API development, we are hiding the auto-generated headers and information. This example is purely exemplary of how the commands can be used, please reference the full command documentation for detailed descriptions of functions.
Generating Token
A POST request is sent to the token command using the apikey
Request:
Response:
This access token will be used for all subsequent commands.
Listing Available Systems
We now want to see which devices are currently available, so call the devices command with the parameter connected=true, the authorization token is now sent in the header as a bearer authorization.
Request:
Response:
With this, we receive a list of all systems which are currently connected to the Customer ID specified in the URL to which the API key corresponds. We have the current running information of the system and the full decoder status.
In particular, we will take note of the FileNo (52), this indicates the device's current file number which we will use to retrieve the desired passings.
Check System Status
Once we have the device we want to use, we can periodically check the system status, this allows us to check if it is still connected, or displaying any errors.
The devices command when used with a specific device ID in the URL returns the status for that system.
Request:
Response:
Focusing on the DecoderStatus we can see that ErrorFlags returns a value of 16 which is due to the Loop Error on the system (with no loop connected).
Retrieve Specific Passings File
Expanding on this further we can now call the passings file which we know is currently active (52), this command will attempt to return all passings for that file.
Note that the maximum which can be returned in a single call is 10,000, if the command returns more than 10,000 it will return an error and you will need to use the fromPassing and amount parameters additionally.
It is recommended to always specify an amount of passings to return to prevent running into errors.
Request:
Response:
Here the full passing record is returned, you may wish to only select fields which are relevant to your application, a full explanation of the passing record is available here.
Retrieve All Passings from Starting Reference
During timing you may want to simply return all passings from when you open a connection regardless of the file number, this can be achieved using the passings command with no file number specified in the URL path but instead supplied as query parameters.
In this example we want to retrieve all passings starting from file 52 onwards, a new file was created (53) with a marker to signify the start of the file.
Request:
Response:
We have PassingNo 3 from file 52 returned and then the next passing is PassingNo1 from file 53. In subsequent calls, we could now start from this reference point.