Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # General API Structure
- 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.
- ## Websocket
- 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
- Camera stream is sent in this format. **We may need to implement an endpoint to start/stop sending stream as it will take lots of bandwidth even if we are not viewing it**. Data format:
- {
- type : 'camera-stream',
- data : string // base64 string
- }
- ## System Status
- System statistics are shown in this format.
- {
- type : 'system-status',
- data : {
- device : {
- cpu : number, // CPU usage. 0 to 100
- ram : number, // RAM usage in MB
- ramMax : number, // RAM capacity in MB
- disk : number, // Disk usage in GB
- diskMax : number, // Disk capacity in GB
- systemTime : number, // Timestamp in ms,
- systemUpTime : number, // In seconds
- },
- processes : [
- {
- id : number, // Id/number of the process,
- serviceUpTime : number, // In seconds
- isRunning : bool
- }
- ]
- }
- }
- ## Firmware Update
- You can send update related activity logs in these objects. I will show them directly in the ui.
- {
- type : 'firmware-update',
- data : string
- }
- ## Session Management
- ### Login
- **POST** : api/login
- **Request Data:**
- {
- username : string,
- password : string
- }
- **Response Data:** No data needed. Just send session id in cookie with `sessionID` key.
- ### Logout (Not urgent)
- **POST** : api/logout
- **Request Data:** none
- **Response Data:** none
- ## Home Page
- ### Get Home Page Details
- **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
- }]
- }
- ## Camera Stream
- ### Start/Stop Stream
- Start if value is true, stop if false. Process id is given in the url.
- You should allow stream from only one process. If there is an active stream when a start request is sent, stop it. Also if a user closes the browser, I cannot send a stop request. You need to end the stream when websocket connection ends.
- **PUT** : api/stream/:processId/streaming
- **Request Data:**
- {
- value : bool
- }
- **Response Data:** no data
- ### Set Stream Quality
- 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/:processId/quality
- **Request Data:**
- {
- value : number // From 0 to 100
- }
- **Response Data:** no data
- ## Settings
- ### Get Settings
- **GET** : api/settings
- **Request Data:** none
- **Response Data:**
- {
- time : Object, // An object containing all time settings
- network : Object // An object containing all network settings
- }
- ### Set Time Settings
- **PUT** : api/settings/time
- **Request Data:** An object containing time settings
- **Response Data:** none
- ### Set Network Settings
- **PUT** : api/settings/network
- **Request Data:** An object containing network settings
- **Response Data:** none
- ### Reset to Factory Settings
- **POST** : api/settings/reset
- **Request Data:** none
- **Response Data:** none
- ## Device Management
- ### Get Management Page Details
- **GET** : api/management/page
- **Request Data:** none
- **Response Data:**
- {
- processes : [{
- id : number,
- direction : string, // Direction of the camera
- isRunning : bool
- }]
- }
- ### Upload New Firmware
- Uploads given file as firmware
- **PUT** : api/firmware
- **Request Data:**
- Data format is FormData. File is sent in `file` property.
- **Response Data:** none
- ### Restart Device
- 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
- ### Restart Process
- 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/processes/:processId/restart
- **Request Data:** none
- **Response Data:** none
- ### Get Logs
- You can view or download logs by using this endpoint. `download` parameter will decide this.
- **GET** : api/logs
- **Request Data:** Send as query parameters
- {
- start : number, // start date. timestamp in ms
- end : number, // end date. timestamp in ms
- process : number, // process id
- limit : number, // number of logs requested for pagination
- skip : number, // number of logs to skip for pagination
- download : boolean // If true download file, if false send results as json response
- }
- **Response Data:**
- [{
- We need to decide this
- }]
- ## Processes (Cameras)
- ### Get Process Settings
- **GET** : api/processes/:processId/settings
- **Request Data:** None
- **Response Data:** An object containing process settings
- ### Update Process Settings
- **PUT** : api/processes/:processId/settings
- **Request Data:** An object containing process settings
- **Response Data:** An object containing processff settings
- ### Get Process Photos
- **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:**
- {
- // We should talk about this
- }
- ### Get Process Videos
- **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:**
- {
- // We should talk about this
- }
- ### Delete Process Video
- **DELETE** : api/processes/:processId/videos/:videoId
- **Request Data:** none
- **Response Data:** none
- ### Create Schedule to Record Video
- **POST** : api/processes/:processId/video-schedules
- **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
- }
- ### Delete Schedule
- Can we delete a schedule while video is being recorded at that time?
- **DELETE** : api/processes/:processId/video-schedules/:scheduleId
- **Request Data:** none
- **Response Data:** none
- ## Centris Related Settings
- ### Get All Centris Related Settings
- **GET** : api/centris-settings
- **Request Data:** none
- **Response Data:**
- {
- device : object, // An object containing device level settings
- processes : [{
- id : number, // Id of the process
- settings : object, // An object containing process settings
- rois : [{
- regions : [{
- points : [ [x1, y1], [x2, y2] ... ],
- countingLine : [ [x1, y1], [x2, y2] ],
- weigh : number,
- laneCount : number
- }]
- }]
- }]
- }
- ### Set Centris Device Settings
- **PUT** : api/centris-settings/device
- **Request Data** : An object containing device level settings
- **Response Data** : An object containing device level settings
- ### Set Centris Process Settings
- **PUT** : api/centris-settings/processes/:processId
- **Request Data** : An object containing process level settings
- **Response Data** : An object containing process level settings
- ## PTS Settings
- ### Get PTS Settings
- **GET** : api/pts-settings
- **Request Data** : none
- **Response Data** :
- {
- device : object, // An object containing device level settings
- processes : [{
- id : number, // Process settings
- settings : object // An object containing process settings
- }]
- }
- ### Set PTS Device Settings
- **PUT** : api/pts-settings/device
- **Request Data** : An object containing device level settings
- **Response Data** : An object containing device level settings
- ### Set PTS Process Settings
- **PUT** : api/pts-settings/processes/:processId
- **Request Data** : An object containing process level settings
- **Response Data** : An object containing process level settings
- ## Meta Data
- ### Get Meta Data For a Form
- 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
Add Comment
Please, Sign In to add comment