All request endpoint urls start with api/
. Data is sent and received as JSON objects. All request data is sent in the request body if not specified otherwise. You should return 200
for success responses and any code that starts with 4
for error responses.
Date values should be sent and received as unix timestamps in milliseconds.
All live data sent over websocket. We will have a single connection. Thus a data format is necessary to differentiate the data. This is the data format:
{
type : string, // camera-stream, firmware-update, etc. We should decide on these.
data : any // Put data here. It can by anything: number, string, object etc.
}
Camera stream is sent in this format. I assume that frame/image encoding is JPEG. Data format:
{
type : 'camera-stream',
data : string // base64 string
}
System statistics are shown in this format.
{
type : 'device-info',
data : {
cpu : number, // CPU usage. 0 to 100
ram : number, // RAM usage in KB
ramMax : number, // RAM capacity in KB
swap : number, // RAM usage in KB
swapMax : number, // Swap capacity in KB
disk : number, // Disk usage in KB
diskMax : number, // Disk capacity in KB
systemTime : number, // Timestamp in ms,
systemUptime : number, // In seconds
}
}
Process statistics are shown in this format.
{
type : 'process-info',
data : [{
id : number,
serviceUptime : number, // In seconds
isRunning : boolean
}]
}
You can send update related activity logs in these objects. I will show them directly in the ui.
{
type : 'firmware-update',
data : string
}
POST : api/login
Request Data:
{
username : string,
password : string
}
Response Data: No data needed. Just send session id in cookie with sessionID
key.
POST : api/logout
Request Data: none
Response Data: none
GET : api/home/page
Request Data: none
Response Data:
{
version : string, // Firmware version
city : string,
junction : string, // Junction name
cameras : [{
id : number, // Camera process id
direction : string, // Name of the direction/street
}]
}
Get the list of stream names and their translations for all processes.
GET : api/stream/list
Request Data: none
Response Data:
[{
processId : number,
streamId : number,
name : string,
label : {
tr : string, // This will be shown in the UI if language is Turkish
en : string
...
}
}]
You should allow stream from only one process. If there is an active stream when a start request is sent, stop it.
POST : api/stream/start
Request Data:
{
processId : number,
streamId : number,
name : string // Name of the stream
}
If a user closes the browser, I cannot send a stop request. You need to end the stream when websocket connection ends.
POST : api/stream/stop
Request Data: no data
Response Data: no data
Set quality for current session. I may start and stop streams. All of them should use the same quality value until websocket connection ends.
PUT : api/stream/quality
Request Data:
{
value : number // From 0 to 100
}
Response Data: no data
GET : api/settings/network
Request Data: none
Response Data: An object containing all network settings or array of them
GET : api/settings/time
Request Data: none
Response Data: An object containing all time settings or array of them
PUT : api/settings/time
Request Data: An object containing time settings
Response Data: none
PUT : api/settings/network
Request Data: An object containing network settings
Response Data: none
POST : api/settings/reset
Request Data: none
Response Data: none
GET : api/services/list
Request Data: none
Response Data:
[{
id : number,
alias : string,
isRunning : bool,
isEnabled : bool
}]
POST : api/services/:serviceId/restart
Request Data: none
Response Data: none
POST : api/services/:serviceId/enable
Request Data: none
Response Data: none
POST : api/services/:serviceId/disable
Request Data: none
Response Data: none
Uploads given file as firmware
PUT : api/firmware
Request Data:
Data format is FormData. File is sent in file
property.
Response Data: none
POST : api/device/start-live-device-info
Request Data: none
Response Data: no data
POST : api/device/stop-live-device-info
Request Data: no data
Response Data: no data
It would be better if you send the response first, then restart the device. Otherwise I cannot know if operation failed or succeeded.
POST : api/device/restart
Request Data: none
Response Data: none
There are multiple streams where logs can be sent. This request gets the list of stream names with their labels in different languages.
GET : api/logs/streams
Request Data: none
Response Data:
[{
name : string, // Name of the string
label : {
tr : string, // This is the title that user will see in Turkish
en : string, // Title in English
<language code> : string // You can add labels for other languages as well.
}
}]
You can view or download logs by using this endpoint. download
parameter will decide this.
GET : api/logs/process/:processId
Request Data: none
Response Data: A file download response should be sent
POST : api/app/check-ntp-server-access
Request Data:
{
ip : string
}
Response Data:
{
hasAccess : boolean
}
GET : api/app/device-info
Request Data: none
Response Data:
{
system : 'chaos' | 'pts' | 'epics'
}
GET : api/cameras/list
Request Data: none
Response Data:
[{
id : number,
direction : string // Direction of the camera so that we can know which one is which.
}]
GET : api/cameras/:id/settings
Request Data: none
Response Data: An object described in meta-data
PUT : api/cameras/:id/settings
Request Data: An object described in meta-data
Response Data: none
This is the ROI data format. Point coordinates are not pixel values. They are relative values between 0 and 1. 0 corresponds to left or top of the frame and 1 corresponds to right or bottom of the frame.
{
id : number,
regions : [{
points : [ [x1, y1], [x2, y2] ... ],
weight : number,
laneCount : number
}],
countingLine : [ [x1, y1], [x2, y2] ]
}
GET : api/processes/list
Request Data: None
Response Data:
[{
id : number,
direction : string, // Name of the camera direction,
settings : object // An object defined in meta-data file,
rois : ROI[]
}]
POST : api/processes/list
Request Data:
{
vieroId : number
}
Response Data:
{
id : number,
vieroId : number,
direction : string
}
DELETE : api/processes/list/:processId
Request Data: None
Response Data: None
PUT : api/processes/:processId/settings
Request Data: An object containing process settings
Response Data: An object containing processff settings
ROIs are updated as a whole. When a ROI is deleted or a new one added, we update whole roi list.
PUT : api/processes/:processId/rois
Request Data: A list of objects which contain roi details
Response Data: none
GET : api/processes/:processId/photos
Request Data: Sent as query parameters
{
limit : number, // Number of photos to return, for pagination
skip : number, // Number of photos to skip, for pagination
}
Response Data:
[{
id : number,
plate : string,
date : string, // Unix timestamp in milliseconds
path : string, // Path relative to root public directory
}]
DELETE : api/processes/:processId/photos/:photoId
Request Data: none
Response Data: none
GET : api/processes/:processId/videos
Request Data: Sent as query parameters
{
limit : number, // Number of videos to return, for pagination
skip : number, // Number of videos to skip, for pagination
}
Response Data:
[{
id : number,
start : number, // Video start date in ms
end : number, // Video end date in ms
path : string,
type : string // processed, unprocessed etc.
}]
DELETE : api/processes/:processId/videos/:videoId
Request Data: none
Response Data: none
GET : api/processes/:processId/video-schedule
Request Data: None
Response Data:
[{
id : number, // You should put id or any idendification info on these so that we can delete or update them
start : number,
end : number,
type : number
}]
POST : api/processes/:processId/video-schedule
Request Data:
{
start : number, // timestamp in ms. recording should start at this moment
end : number, // timestamp in ms. recording should stop at this moment
type : string // Recording type
}
Response Data:
{
id : number, // You should put id or any idendification info on these so that we can delete or update them
start : number,
end : number,
type : string
}
Can we delete a scheduled recording while video is being recorded at that time?
DELETE : api/processes/:processId/video-schedule/:taskId
Request Data: none
Response Data: none
POST : api/processes/start-live-status-stream
Request Data: none
Response Data: no data
POST : api/processes/stop-live-status-stream
Request Data: no data
Response Data: no data
Stream sources for chaos processes. Get list, create, update, delete. Stream sources are update via meta-data forms. Because of that properties of streams aren't listed here. You can define them as you like.
GET : api/streams/list
Request Data : none
Response Data : List of objects. Results should contain id
, resourceType
and resource
properties to show them in the list.
POST : api/streams/list
Request Data : An object containing stream details.
Response Data : none
PUT : api/streams/list/:streamId
Request Data : An object containing stream details.
Response Data : none
DELETE : api/streams/list/:streamId
Request Data : none
Response Data : none
GET : api/centris-settings/page
Request Data : none
Response Data : Centris and Viero lists. Centris list is a list of centris ip and ports. Each record contains the list of vieros which send data to that centris.
{
centrises : [{
ip : string, // IP of the centris
port : number, // Port of the centris
vieros : number[] // List of ids of vieros which send data to this centris
}],
vieros : [{
id : number,
direction : string // Direction/name of viero
}]
}
PUT : api/centris-settings
Request Data :
[{
ip : string, // IP of the centris
port : number, // Port of the centris
vieros : number[] // List of ids of vieros which send data to this centris
}]
Response Data : none
GET : api/pts-settings
Request Data : none
Response Data :
{
ftpSettings : object, // An object containing ftp settings
processes : [{
id : number, // Viero/process id
direction : string, // Name of the viero/process direction
processorSettings : object, // An object containing processor settings
typeBrandSettings : object // An object containing type-brand settings
}]
}
PUT : api/pts-settings/ftp-settings
Request Data : An object containing ftp settings
Response Data : None
PUT : api/pts-settings/processes/:processId/processor
Request Data : An object containing processor settings
Response Data : none
PUT : api/pts-settings/processes/:processId/type-brand
Request Data : An object containing type-brand settings
Response Data : none
Form name is sent in the url. It can be one of these values : time
, network
, process
, centris
, pts
.
I will create the initial versions of these pages. You can modify them whenever you need.
GET : api/meta-data/:formName
Request Data : none
Response Data : An object containing form metadata