All Response(JSON):

Response (JSON):

            {
                "success": boolean,
                "code": number,
                "data": object | null,
                "message": string,
                "internal_code": number
            }

            

Description:

All requests sent to the API receive a standard response in JSON format. This response contains information about whether the request was successful or not, the status code, the returned data, and the internal error code.

success

This field indicates whether the request was successfully processed or not.

  • A value of true means the operation was successful.
  • A value of false indicates that an error occurred while processing the request.

code

This field represents the HTTP status code that indicates the result of the request.

data

If the request is successful, the returned data from the API will be placed in this field.

The data type can be a JSON object, an array, or another value.

If the request has no data to return, or if an error occurs, this field will be set to null.

message

This field contains a general descriptive message about the API response.

To view the detailed explanation of each error, you must refer to the internal error code (internal_code) and the error message table in the documentation.

internal_code

This field is an internal API error code used to identify the exact type of error.

These codes are defined in the API message reference file, and each code has a specific explanation.

Login

No auth required

Endpoint:

POST /Api/Aut/Login

Request (JSON):

                {
                "username": "root",
                "password": "****"
                }
            

Response . data (JSON):

              {
               "internal_code": 0,
               "message": "Please read the keys file and the code comments to understand the error.",
                  "data": {"token": "root|admin|1780690487.97ea1d3.."},
                  "code": 200,
                  "success": true
             }
            

Description:

Authenticates a user and returns a JWT token valid for 10 minutes.

Change Password

Auth: Bearer token Role: all

Endpoint:

POST /Api/Aut/ChangePassword

Headers:

Authorization: Bearer <token>
    

Request (JSON):

{
    "password": "new_password",
    "repeatpassword": "new_password"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": null,
    "message": "Password changed successfully",
    "internal_code": 2002
}
    

Description:

This endpoint allows an authenticated user to change their account password.

  • Requires a valid JWT token.
  • Password must be between 6 and 32 characters.
  • password and repeatpassword must match.
  • Error details are identified using internal_code.

Get API Sender Status

Auth: Bearer token Role: all

Endpoint:

GET /Api/Get/ApiServer

Headers:

Authorization: Bearer <token>
    

Response . data (JSON):

{
    "api_sebder": true,
    "ip_addr": "192.168.1.100",
    "port_addr": "8080",
    "token": "xxxxxx",
    "messages": [
        {
            "timestamp": 1717580000,
            "message": "Sample message"
        }
    ]
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": { ... },
    "message": "Success",
    "internal_code": 0
}
    

Description:

Returns the configuration and status of the API sender service.

  • Includes API sender enable/disable state.
  • Provides server IP, port, and authentication token.
  • Returns recent message history with timestamps.

Set API Sender

Auth: Bearer token Role: all

Endpoint:

POST /Api/Set/ApiServer

Headers:

Authorization: Bearer <token>
    

Request (JSON):

{
    "api_sebder": true,
    "ip_addr": "192.168.1.100",
    "port_addr": "8080",
    "token": "xxxxxx"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": null,
    "message": "Operation completed",
    "internal_code": 2015
}
    

Description:

Configures the API sender service settings.

  • Requires valid IP address format.
  • Allows enabling or disabling API sender.
  • Saves configuration persistently.
  • Error details are identified using internal_code.

Camera ROI & Zones

Auth: Bearer token Role: all

Endpoint:

GET /Api/Get/ZoonRoi?cam=1

Headers:

Authorization: Bearer <token>
    

Query Params:

cam = camera id (optional, default = 1)
    

Response . data (JSON):

{
    "camId": 1,
    "Original_width": 1920,
    "Original_height": 1080,
    "roi": {
        "x": 100,
        "y": 200,
        "width": 800,
        "height": 400
    },
    "zones": [
        {
            "points": [
                { "x": 10, "y": 20 },
                { "x": 30, "y": 40 }
            ]
        }
    ]
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": { ... },
    "message": "Success",
    "internal_code": 0
}
    

Description:

Returns Region of Interest (ROI) and detection zones for a specific camera.

  • Supports multi-camera via cam parameter.
  • ROI defines detection area.
  • Zones are defined as polygon points.

Set Zone & ROI

Auth: Bearer token Role: admin

Endpoint:

POST /Api/Set/ZoonRoi

Headers:

Authorization: Bearer <token>
    

Body (JSON):

{
    "camId": 1,
    "roi": {
        "x": 100,
        "y": 50,
        "width": 400,
        "height": 300
    },
    "zones": [
        {
            "points": [
                {"x": 10, "y": 10},
                {"x": 200, "y": 10},
                {"x": 200, "y": 200},
                {"x": 10, "y": 200}
            ]
        }
    ]
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "message": "Saved successfully",
    "internal_code": 2005
}
    

Description:

Sets Region of Interest (ROI) and detection zones for the camera.

  • ROI defines the main processing area.
  • Zones are polygons used for detection filtering.
  • All previous zones are replaced on update.

Camera Configuration

Auth: Bearer token Role: all

Endpoint:

GET /Api/Get/CamConfig?cam=1

Headers:

Authorization: Bearer <token>
    

Query Params:

cam = camera id (optional, default = 1)
    

Response . data (JSON):

{
    "camId": 1,
    "maxFrame": 5,
    "camEnabel": true,
    "PX_TO_KMH": 0.12,
    "camName": "Camera 1",
    "ShutterSpeed": 120,
    "GainSpeed": 10,
    "Protocol": "rtsp",
    "IP": "192.168.1.50",
    "Port": 554,
    "Path": "/stream",
    "User": "admin",
    "Pass": "1234"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": { ... },
    "message": "Success",
    "internal_code": 0
}
    

Description:

Returns configuration details for a specific camera.

  • Supports multiple cameras via cam parameter.
  • Includes detection and speed calculation parameters.
  • Returns stream connection details (for supported camera models).

Set Network Time Response

Auth: Bearer token Role: admin

Endpoint:

POST /Api/Set/CamConfig

Headers:

Authorization: Bearer <token>
    

Body (JSON):

{
    "camId": 1,
    "camEnabel": true,
    "Protocol": "rtsp",
    "IP": "192.168.1.50",
    "Port": 554,
    "Path": "/stream",
    "User": "admin",
    "Pass": "1234",
    "maxFrame": 5,
    "PX_TO_KMH": 0.12,
    "camName": "Camera 1",
    "ShutterSpeed": 120,
    "GainSpeed": 10
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "message": "Saved successfully",
    "internal_code": 2005
}
    

Description:

Updates camera configuration and applies shutter & gain settings to the device.

  • Some fields are required depending on camera mode.
  • Shutter and gain values are normalized before applying.
  • If applying to camera fails, config is still saved.

Network & Time Settings

Auth: Bearer token Role: all

Endpoint:

GET /Api/Get/NetTimReset

Headers:

Authorization: Bearer <token>
    

Response . data (JSON):

{
    "eth_ip": "192.168.1.10",
    "eth_netmask": "255.255.255.0",
    "gateway": "192.168.1.1",
    "ntp_server": "pool.ntp.org",
    "reset_time": "03:00",
    "reset_enabled": "true",
    "timezone": "Asia/Tehran",
    "date_server": "2026-06-05T12:00"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": { ... },
    "message": "Success",
    "internal_code": 0
}
    

Description:

Returns current network configuration and system time settings.

  • Includes IP, subnet mask, and gateway.
  • Provides NTP server and timezone.
  • Returns scheduled reset configuration.
  • date_server is formatted for datetime-local inputs.

Set Device IP

Auth: Bearer token Role: all

Endpoint:

POST /Api/Set/NetTimReset/IP

Headers:

Authorization: Bearer <token>
    

Body (JSON):

{
    "eth_ip": "192.168.10.5",
    "eth_netmask": 24,
    "gateway": "192.168.10.1"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "message": "Network updated",
    "internal_code": 2006
}
    

Description:

Configures system network settings using Netplan.

  • IP and gateway are validated before applying.
  • System network is restarted after update.
  • RTSP service is restarted automatically.

Set System Time

Auth: Bearer token Role: all

Endpoint:

POST /Api/Set/NetTimReset/TimeCam

Headers:

Authorization: Bearer <token>
    

Body (JSON):

{
    "time": "2026-06-05 14:30:00"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "message": "Time updated",
    "internal_code": 2014
}
    

Description:

Sets system date and time manually.

  • Time must be in valid format.
  • System time service is restarted after update.

Set Time Zone

Auth: Bearer token Role: all

Endpoint:

POST /Api/Set/NetTimReset/TimeZone

Headers:

Authorization: Bearer <token>

Body (JSON):

{
    "time_zone": "Asia/Tehran"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "message": "Timezone updated",
    "internal_code": 2013
}
    

Description:

Sets system timezone using timedatectl and restarts time service.

Set NTP Server

Auth: Bearer token Role: all

Endpoint:

POST /Api/Set/NetTimReset/NTPserver

Headers:

Authorization: Bearer <token>

Body (JSON):

{
    "ntp_server": "pool.ntp.org"
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "message": "NTP updated",
    "internal_code": 2007
}
    

Description:

Updates system NTP configuration and restarts time synchronization service.

System Status

Auth: Bearer token Role: all

Endpoint:

GET /Api/Call/StatusSystem

Headers:

Authorization: Bearer <token>
    

Response . data (JSON):

{
    "uptime": 123456,
    "ram_usage_percent": 45.2,
    "ram_free": 1024,
    "cpu_usage_percent": 23.5,
    "cpu_avg": 0.85,
    "cpu_temp": 55.3,
    "disk_free": 120,
    "disk_total": 256,
    "current_time": "2026-06-05 12:00:00",
    "number_of_plates_today": 150,
    "average_speed_today": 72.4,
    "minimum_speed_today": 40,
    "maximum_speed_today": 120,
    "number_of_cameras": 2
}
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": { ... },
    "message": "Success",
    "internal_code": 0
}
    

Description:

This endpoint returns real-time system and ANPR statistics.

  • Provides CPU, RAM, disk, and uptime information.
  • Includes ANPR statistics such as plate count and speed metrics.
  • Returns current system time.
  • All details are returned inside the data field.

Get Image

No Auth Public

Endpoint:

GET /api/Getimage?path=...

Query Params:

path = relative image path (required)
    

Response:

Content-Type: image/jpeg
Body: binary image data
    

Description:

Returns an image file from server filesystem using relative path.

Report Get

Auth: Bearer token Role: all

Endpoint:

GET /Api/Report/Get

Headers:

Authorization: Bearer <token>
    

Query Params:

start = unix timestamp (required)
end = unix timestamp (required)
skip = offset (optional)
limit = max rows (optional, default 50, max 1000)
plate_text = filter plate (optional)
cnf = confidence filter (optional)
camnu = camera id (optional)
    

Response (JSON):

{
    "success": true,
    "code": 200,
    "data": {
        "total": 1200,
        "data": [
            {
                "plate": "12A345BC",
                "time": "1710000000",
                "speed": "80"
            }
        ]
    },
    "message": "Success",
    "internal_code": 0
}
    

Description:

Returns filtered ANPR report data with pagination and optional filters.

Frame Stream

No Auth Public

Endpoint:

GET /frame/<id>

Path Param:

id = camera id
    

Response:

Content-Type: image/jpeg
Body: binary frame data
    

Description:

Returns real-time JPEG frame from selected camera stream.

WebSocket Events

Auth: Bearer token Role: all

Endpoint:

ws://yourserver/ws?token=YOUR_TOKEN

Description:

After authentication with a valid token, the server pushes real-time events to the client.

Events

1. ReadyFrame

Message (JSON):

{ "event": "ReadyFrame", "stats": "123", "cam": "1", "motion": "true" }

Description:

Indicates a new frame is ready with statistics, camera number, and motion detection flag.

2. DisconnectCam

Message (JSON):

{ "message": "❌ RTSP connection failed. Retrying...", "event": "DisconnectCam" }

Description:

Sent when the RTSP connection to the camera fails.

3. ConnectCam

Message (JSON):

{ "message": "✅ RTSP connection established.", "event": "ConnectCam" }

Description:

Sent when the RTSP connection to the camera is successfully established.

4. ReadyPlate

Message (JSON):

{ "event": "ReadyPlate", "phat": "/path/to/plate.jpg", "plate": "ABC123", "Confidence": "0.92", "speed": "45" }

Description:

Indicates a license plate was detected, including image path, recognized text, confidence score, and speed.