Skip to content

GB28181 API

The GB28181 plugin provides a complete GB/T 28181 protocol API, supporting device access management, channel queries, PTZ control, recording query and playback, and cascade platform integration.

features = ["gb28181"]
GET /gb28181/devices

Returns all registered GB/T 28181 devices.

Response example:

{
"code": 0,
"message": "success",
"data": {
"total": 2,
"devices": [
{
"device_id": "34020000001320000001",
"name": "Front Door Camera",
"manufacturer": "Hikvision",
"model": "DS-2CD2T45",
"firmware": "V5.6.2",
"transport": "UDP",
"status": "online",
"ip": "192.168.1.100",
"port": 5060,
"register_time": "2026-03-18T08:00:00Z",
"keepalive_time": "2026-03-18T14:30:00Z",
"channel_count": 4
}
]
}
}
GET /gb28181/device/{device_id}

Returns detailed information for the specified device.

DELETE /gb28181/device/{device_id}

Remove the specified device from the system.

Response example:

{
"code": 0,
"message": "success",
"data": {
"device_id": "34020000001320000001",
"status": "removed"
}
}
POST /gb28181/device/{device_id}/refresh

Send a Catalog query to the device to refresh device information and channel list.

GET /gb28181/device/{device_id}/channels

Returns all channels for the specified device.

Response example:

{
"code": 0,
"message": "success",
"data": {
"device_id": "34020000001320000001",
"total": 4,
"channels": [
{
"channel_id": "34020000001310000001",
"name": "Channel 1",
"manufacturer": "Hikvision",
"status": "ON",
"ptz_type": 3,
"longitude": 116.397428,
"latitude": 39.90923,
"has_audio": true
}
]
}
}
POST /gb28181/device/{device_id}/channel/{channel_id}/invite
Content-Type: application/json
{
"stream_path": "gb/34020000001310000001",
"transport": "TCP",
"ssrc": ""
}

Send an Invite request to the device to start live video preview. On success, the stream is published to the specified stream_path.

ParameterTypeDescription
stream_pathstringStream publish path (optional, auto-generated by default)
transportstringTransport method: UDP or TCP (default UDP)
ssrcstringSSRC (optional, auto-assigned by default)

Response example:

{
"code": 0,
"message": "success",
"data": {
"stream_path": "gb/34020000001310000001",
"ssrc": "0200000001",
"status": "inviting"
}
}
POST /gb28181/device/{device_id}/channel/{channel_id}/bye

Stop the live preview by sending a BYE request to the device.

POST /gb28181/device/{device_id}/channel/{channel_id}/ptz
Content-Type: application/json
{
"command": "left",
"speed": 128,
"priority": 1
}

Control the camera’s pan-tilt direction and lens zoom.

CommandDescription
upPan up
downPan down
leftPan left
rightPan right
upleftPan upper-left
uprightPan upper-right
downleftPan lower-left
downrightPan lower-right
zoominZoom in
zoomoutZoom out
focusnearFocus near
focusfarFocus far
irisinIris open
irisoutIris close
stopStop movement
ParameterRangeDescription
speed1-255Movement speed, 128 is medium
priority0-15Control priority, higher value means higher priority

Pan left:

Terminal window
curl -X POST http://localhost:8080/gb28181/device/34020000001320000001/channel/34020000001310000001/ptz \
-H "Content-Type: application/json" \
-d '{"command": "left", "speed": 128}'

Zoom in:

Terminal window
curl -X POST http://localhost:8080/gb28181/device/34020000001320000001/channel/34020000001310000001/ptz \
-H "Content-Type: application/json" \
-d '{"command": "zoomin", "speed": 64}'

Stop:

Terminal window
curl -X POST http://localhost:8080/gb28181/device/34020000001320000001/channel/34020000001310000001/ptz \
-H "Content-Type: application/json" \
-d '{"command": "stop"}'
POST /gb28181/device/{device_id}/channel/{channel_id}/preset
Content-Type: application/json
{
"action": "goto",
"preset_id": 1
}
ActionDescription
setSave current position as preset
gotoMove to specified preset
removeDelete preset
POST /gb28181/device/{device_id}/channel/{channel_id}/records
Content-Type: application/json
{
"start_time": "2026-03-18T00:00:00Z",
"end_time": "2026-03-18T23:59:59Z",
"type": "all",
"page": 1,
"page_size": 50
}
ParameterTypeDescription
start_timeRFC3339Query start time
end_timeRFC3339Query end time
typestringRecording type: all, alarm, manual, timer
pageintPage number
page_sizeintItems per page

Response example:

{
"code": 0,
"message": "success",
"data": {
"total": 24,
"records": [
{
"name": "record_001",
"start_time": "2026-03-18T08:00:00Z",
"end_time": "2026-03-18T09:00:00Z",
"type": "timer",
"file_size": 1073741824
}
]
}
}
POST /gb28181/device/{device_id}/channel/{channel_id}/playback
Content-Type: application/json
{
"start_time": "2026-03-18T08:00:00Z",
"end_time": "2026-03-18T09:00:00Z",
"stream_path": "playback/34020000001310000001",
"speed": 1.0
}

Initiate a recording playback request. The device pushes recording data to the engine.

ParameterTypeDescription
start_timeRFC3339Playback start time
end_timeRFC3339Playback end time
stream_pathstringPlayback stream path
speedfloatPlayback speed (0.25 / 0.5 / 1.0 / 2.0 / 4.0)
POST /gb28181/device/{device_id}/channel/{channel_id}/playback/control
Content-Type: application/json
{
"action": "pause"
}
ActionDescription
pausePause playback
resumeResume playback
speedChange playback speed (with speed parameter)
seekSeek to specified time (with position parameter)
stopStop playback
POST /gb28181/device/{device_id}/channel/{channel_id}/download
Content-Type: application/json
{
"start_time": "2026-03-18T08:00:00Z",
"end_time": "2026-03-18T09:00:00Z",
"speed": 4.0
}

Download device recordings to local storage at the specified playback speed.

GET /gb28181/cascades

Returns information for all configured upstream platforms.

Response example:

{
"code": 0,
"data": {
"total": 1,
"cascades": [
{
"platform_id": "34020000002000000001",
"name": "City-level Platform",
"address": "10.0.0.100:5060",
"transport": "TCP",
"status": "registered",
"register_time": "2026-03-18T08:00:00Z"
}
]
}
}
POST /gb28181/cascade/register
Content-Type: application/json
{
"platform_id": "34020000002000000001",
"address": "10.0.0.100:5060",
"transport": "TCP",
"username": "34020000001320000001",
"password": "password123",
"expires": 3600
}
POST /gb28181/cascade/{platform_id}/unregister
POST /gb28181/cascade/{platform_id}/push_channels
Content-Type: application/json
{
"channel_ids": [
"34020000001310000001",
"34020000001310000002"
]
}

Push local channel information to the upstream platform, allowing the upstream platform to view and control these channels.