---
title: Developer documentation
slug: developer-documentation
description: Learn how to implement a REST API for controlling or viewing a camera using the Bluecherry API. Find the device ID in the XML file and use the default web port 7001 and RTSP port 7002. Get commands for live viewing via RTSP and capturing JPEG images. Expl
docTags: 
createdAt: 2021-03-03T02:49:28.000Z
---

We are currently working on a REST API, for now these are basic commands you can implement

Using the Bluecherry API to control or view a camera requires knowing the device ID. Currently this can be found in the XML file.

Note: The XML file will only generate the device IDs that the user has access to. Make sure you have access to all cameras, or that you are using an administrator login if you plan on controlling all cameras.



:::hint{type="warning"}
By default the web port is 7001 (configurable in Apache settings) and the RTSP port is 7002.
:::





```curl
https://login:password@bluecherry-server:7001/ajax/devices.php?XML=true&short=true

```

## Live viewing

### &#xA;RTSP (TCP) connection



```curl
rtsp://login:password@bluecherry-server:7002/live/$deviceid
```

### Return Multi-part JPEG (MJPEG)&#xA;

```curl
https://login:password@bluecherry-server:7001/media/mjpeg.php?id={camera_id}&multipart=true

```

### Return single image (JPEG)


Obtain one image from the server:

```curl
https://login:password@bluecherry-server:7001/media/mjpeg.php?id={camera_id}
```



## Controlling PTZ cameras







Below is a example URL for controlling a Pan / Tilt / Zoom camera through the Bluecherry API.



```curl
https://login:password@bluecherry-server/media/ptz.php?id={camera_id}&command={command}&panspeed={speed}&tiltspeed={speed}&pan={pan_command}&tilt={tilt_command}&zoom={zoom-command}&duration={duration}&preset={preset_id}&name={preset_name}

```

**Supported Pan / Tilt / Zoom commands:**

query – display XML with camera information/PTZ capabilities and&#x20;

presets move – pan/tilt/zoom using parameters&#x20;

stop – stop movement&#x20;

save – save present&#x20;

rename – rename a preset&#x20;

go – go to specified preset&#x20;

clear – clear preset

**Pan / Tilt / Zoom Variables:**


preset\_id – id of the preset preset\_name –new preset name speed: pan/tilt speed pan\_command:(l)eft /right tilt\_command:(u)p /(d)own zoom\_command:(t)ight /(w)ide duration\:for how long to execute command; -1 for continuous

## Trigger recordings



```curl
https://login:password@bluecherry-server:7001/media/trigger.php?camera_id={camera_id}&description=TEST


```

Camera must be set to Trigger (‘T’) in the recording schedule. Description will show in the logs that a trigger was recording with the description you inserted.


