1Overview
PTZF control consists of two endpoints:
/camera_move— real-time movement (Pan/Tilt/Zoom/Focus). Continuous movement follows a "press to start, release to stop" model./camera_preset— presets: save the current position, load a saved position, or clear.
Both are protected endpoints and require you to log in first to obtain a token (token) — see the Login API guide.
Stop on release, otherwise the camera will keep moving until it reaches its limit.2Connection Info
| Protocol | Default Port | Base URL |
|---|---|---|
| HTTP | 80 | http://<camera-ip>/ |
| HTTPS | 443 | https://<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
Controls camera movement along a single axis. Diagonal movement (simultaneous Pan+Tilt) requires a separate request for each of the two axes.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
method | string | Yes | Fixed as "SetPtzf" |
axis | int | Yes | Movement axis, see table below |
dir | int | Yes | Movement direction, see table below |
cmd | int | Yes | Command: 0=Step (single step), 1=Start, 2=Stop |
axis · Axis
| Value | Axis | dir=0 | dir=1 |
|---|---|---|---|
0 | Pan | right | left |
1 | Tilt | up | down |
2 | Zoom | zoom in (Tele) | zoom out (Wide) |
3 | Focus | near (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)
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
| Field | Type | Required | Description |
|---|---|---|---|
method | string | Yes | Fixed as "SetPreset" |
operate | int | Yes | Action: 0=load (Restore/Load), 1=save (Save), 2=clear (Clear) |
id | int | Yes | Preset 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 }
/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> }
| HTTP | Message | Meaning |
|---|---|---|
200 | ok | Command accepted |
400 | invalid params | Malformed request, or axis/dir/cmd out of range |
401 | token malformed / failed | Token missing, malformed, or not accepted |
401 | token password error | Token invalidated (usually because the password was changed); log in again |
500 | — | Device-side execution failed or not yet ready |