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.
Enabling the Plugin
Section titled “Enabling the Plugin”features = ["gb28181"]Device Management
Section titled “Device Management”Query Device List
Section titled “Query Device List”GET /gb28181/devicesReturns 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 } ] }}Query Single Device
Section titled “Query Single Device”GET /gb28181/device/{device_id}Returns detailed information for the specified device.
Delete Device
Section titled “Delete 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" }}Refresh Device Info
Section titled “Refresh Device Info”POST /gb28181/device/{device_id}/refreshSend a Catalog query to the device to refresh device information and channel list.
Channel Management
Section titled “Channel Management”Query Device Channels
Section titled “Query Device Channels”GET /gb28181/device/{device_id}/channelsReturns 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 } ] }}Live Preview (Invite)
Section titled “Live Preview (Invite)”POST /gb28181/device/{device_id}/channel/{channel_id}/inviteContent-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.
| Parameter | Type | Description |
|---|---|---|
stream_path | string | Stream publish path (optional, auto-generated by default) |
transport | string | Transport method: UDP or TCP (default UDP) |
ssrc | string | SSRC (optional, auto-assigned by default) |
Response example:
{ "code": 0, "message": "success", "data": { "stream_path": "gb/34020000001310000001", "ssrc": "0200000001", "status": "inviting" }}Stop Preview (Bye)
Section titled “Stop Preview (Bye)”POST /gb28181/device/{device_id}/channel/{channel_id}/byeStop the live preview by sending a BYE request to the device.
PTZ Control
Section titled “PTZ Control”Send PTZ Command
Section titled “Send PTZ Command”POST /gb28181/device/{device_id}/channel/{channel_id}/ptzContent-Type: application/json
{ "command": "left", "speed": 128, "priority": 1}Control the camera’s pan-tilt direction and lens zoom.
Command List
Section titled “Command List”| Command | Description |
|---|---|
up | Pan up |
down | Pan down |
left | Pan left |
right | Pan right |
upleft | Pan upper-left |
upright | Pan upper-right |
downleft | Pan lower-left |
downright | Pan lower-right |
zoomin | Zoom in |
zoomout | Zoom out |
focusnear | Focus near |
focusfar | Focus far |
irisin | Iris open |
irisout | Iris close |
stop | Stop movement |
Speed Parameters
Section titled “Speed Parameters”| Parameter | Range | Description |
|---|---|---|
speed | 1-255 | Movement speed, 128 is medium |
priority | 0-15 | Control priority, higher value means higher priority |
PTZ Control Examples
Section titled “PTZ Control Examples”Pan left:
curl -X POST http://localhost:8080/gb28181/device/34020000001320000001/channel/34020000001310000001/ptz \ -H "Content-Type: application/json" \ -d '{"command": "left", "speed": 128}'Zoom in:
curl -X POST http://localhost:8080/gb28181/device/34020000001320000001/channel/34020000001310000001/ptz \ -H "Content-Type: application/json" \ -d '{"command": "zoomin", "speed": 64}'Stop:
curl -X POST http://localhost:8080/gb28181/device/34020000001320000001/channel/34020000001310000001/ptz \ -H "Content-Type: application/json" \ -d '{"command": "stop"}'Preset Control
Section titled “Preset Control”POST /gb28181/device/{device_id}/channel/{channel_id}/presetContent-Type: application/json
{ "action": "goto", "preset_id": 1}| Action | Description |
|---|---|
set | Save current position as preset |
goto | Move to specified preset |
remove | Delete preset |
Recording Query
Section titled “Recording Query”Query Device Recordings
Section titled “Query Device Recordings”POST /gb28181/device/{device_id}/channel/{channel_id}/recordsContent-Type: application/json
{ "start_time": "2026-03-18T00:00:00Z", "end_time": "2026-03-18T23:59:59Z", "type": "all", "page": 1, "page_size": 50}| Parameter | Type | Description |
|---|---|---|
start_time | RFC3339 | Query start time |
end_time | RFC3339 | Query end time |
type | string | Recording type: all, alarm, manual, timer |
page | int | Page number |
page_size | int | Items 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 } ] }}Recording Playback
Section titled “Recording Playback”POST /gb28181/device/{device_id}/channel/{channel_id}/playbackContent-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.
| Parameter | Type | Description |
|---|---|---|
start_time | RFC3339 | Playback start time |
end_time | RFC3339 | Playback end time |
stream_path | string | Playback stream path |
speed | float | Playback speed (0.25 / 0.5 / 1.0 / 2.0 / 4.0) |
Playback Control
Section titled “Playback Control”POST /gb28181/device/{device_id}/channel/{channel_id}/playback/controlContent-Type: application/json
{ "action": "pause"}| Action | Description |
|---|---|
pause | Pause playback |
resume | Resume playback |
speed | Change playback speed (with speed parameter) |
seek | Seek to specified time (with position parameter) |
stop | Stop playback |
Recording Download
Section titled “Recording Download”POST /gb28181/device/{device_id}/channel/{channel_id}/downloadContent-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.
Cascade Platform
Section titled “Cascade Platform”Query Cascade Platforms
Section titled “Query Cascade Platforms”GET /gb28181/cascadesReturns 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" } ] }}Register with Upstream Platform
Section titled “Register with Upstream Platform”POST /gb28181/cascade/registerContent-Type: application/json
{ "platform_id": "34020000002000000001", "address": "10.0.0.100:5060", "transport": "TCP", "username": "34020000001320000001", "password": "password123", "expires": 3600}Unregister
Section titled “Unregister”POST /gb28181/cascade/{platform_id}/unregisterPush Channels to Upstream
Section titled “Push Channels to Upstream”POST /gb28181/cascade/{platform_id}/push_channelsContent-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.