API Reference · v1.0

Camera Move API

Describes how to control the camera's PTZF actions (Pan, Tilt, Zoom, Focus) through /camera_move, and how to save and load presets with /camera_preset.

1Overview

PTZF control consists of two endpoints:

Both are protected endpoints and require you to log in first to obtain a token (token) — see the Login API guide.

For continuous movement, always send Stop on release, otherwise the camera will keep moving until it reaches its limit.

2Connection Info

ProtocolDefault PortBase URL
HTTP80http://<camera-ip>/
HTTPS443https://<camera-ip>/

The content type for both requests and responses is application/json, and a token must be included:

Authorization: Bearer <access_token>

3Move Endpoint

POST/camera_moveAuth required

Controls camera movement along a single axis. Diagonal movement (simultaneous Pan+Tilt) requires a separate request for each of the two axes.

Request Parameters

FieldTypeRequiredDescription
methodstringYesFixed as "SetPtzf"
axisintYesMovement axis, see table below
dirintYesMovement direction, see table below
cmdintYesCommand: 0=Step (single step), 1=Start, 2=Stop

axis · Axis

ValueAxisdir=0dir=1
0Panrightleft
1Tiltupdown
2Zoomzoom in (Tele)zoom out (Wide)
3Focusnear (Near)far (Far)

dir has only two values: 0=RightUpInNear (right/up/zoom in/near), 1=LeftDownOutFar (left/down/zoom out/far).

Request · Start panning right

POST /camera_move
Authorization: Bearer <access_token>
Content-Type: application/json

{
  "method": "SetPtzf",
  "axis": 0,
  "dir": 0,
  "cmd": 1
}

Response · 200 OK

{ "code": 200, "msg": "ok", "data": null }

4Preset Endpoint (Save/Load)

POST/camera_presetAuth required

Save, load, or clear a single preset. Save records the current PTZF position; load moves the camera to the position saved for that preset.

Request Parameters

FieldTypeRequiredDescription
methodstringYesFixed as "SetPreset"
operateintYesAction: 0=load (Restore/Load), 1=save (Save), 2=clear (Clear)
idintYesPreset number, range 0–127

Request · Save the current position as preset 0

POST /camera_preset
Authorization: Bearer <access_token>
Content-Type: application/json

{
  "method": "SetPreset",
  "operate": 1,
  "id": 0
}

Request · Load (recall) preset 0

{ "method": "SetPreset", "operate": 0, "id": 0 }

Response · 200 OK

{ "code": 200, "msg": "ok", "data": null }
Before saving, first move the camera to the target position with /camera_move, then send operate=1 to save. If the preset feature is disabled (see ptz_preset_setting), saving will not take effect.

5Usage Examples

Pan right (hold to move, release to stop)

# Start: pan right (axis=Pan, dir=right, cmd=Start)
curl -X POST https://<camera-ip>/camera_move \
  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
  -d '{"method":"SetPtzf","axis":0,"dir":0,"cmd":1}'

# Stop (cmd=Stop; axis/dir same as at start)
curl -X POST https://<camera-ip>/camera_move \
  -H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
  -d '{"method":"SetPtzf","axis":0,"dir":0,"cmd":2}'

Zoom in / zoom out (Zoom)

# Zoom in (Tele)
curl -X POST https://<camera-ip>/camera_move -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"method":"SetPtzf","axis":2,"dir":0,"cmd":1}'
# Zoom out (Wide) uses dir:1; always send cmd:2 to stop

Diagonal movement (up-right)

Diagonal movement requires a separate request for each of the two axes (Pan first, then Tilt); to stop, likewise send one Stop per axis.

# Pan right
curl -X POST https://<camera-ip>/camera_move -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"method":"SetPtzf","axis":0,"dir":0,"cmd":1}'
# Tilt up
curl -X POST https://<camera-ip>/camera_move -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"method":"SetPtzf","axis":1,"dir":0,"cmd":1}'

Save and load a preset

# 1) First move the camera to the target position (omitted, see the camera_move examples above)
# 2) Save the current position as preset 0
curl -X POST https://<camera-ip>/camera_preset -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"method":"SetPreset","operate":1,"id":0}'

# 3) Load it at any time afterward (the camera automatically returns to preset 0)
curl -X POST https://<camera-ip>/camera_preset -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"method":"SetPreset","operate":0,"id":0}'

6Responses and Error Codes

All responses use a uniform JSON structure:

{ "code": <http_status>, "msg": "<message>", "data": <payload> }
HTTPMessageMeaning
200okCommand accepted
400invalid paramsMalformed request, or axis/dir/cmd out of range
401token malformed / failedToken missing, malformed, or not accepted
401token password errorToken invalidated (usually because the password was changed); log in again
500—Device-side execution failed or not yet ready