Camera Tools Command Server

The Camera Tools for GoPro Heros app allows you control multiple GoPro® cameras. The command server is a part of the Camera Tools app and allows you to control the app and cameras via HTTP commands by sending JSON commands to the server. This document describes all available commands.

Note: On Android and iOS the server works only while the app is running in foreground and while the screen in on.

Camera Tools for Heros - ToolsForGoPro.com

Error handling (since Camera Tools 1.4.1)

Each JSON response contains a "status_code" field which can hold one of the following values:

  • 0: No error.
  • -1: Unknown error. Returns HTTP status 400.
  • -2: Command not found. Returns HTTP status 404.
  • -3: Camera(s) not found.
  • -4: No WiFi information available (see getCurrentWiFiSSID() for details).
  • -5: The camera is not connected.
  • -6: Another media query is already running (see queryMediaListAsync() for details).
  • -7: The script ID was not found (see stopScript() for details).

If an error occurs then an optional field "error" can contain additional information in textual form.


Get a list of all cameras

This command returns a list of all cameras installed. As an alternative the cameraStatus function with an empty cameras argument can be used. The status code is always 0 (ok).

Request:
{
	"command": "getAllCameras"
}
Response:
{
    "cameras": [
        {
            "connection_state": "Connected",
            "name": "GoPro 1953"
        },
        {
            "connection_state": "Disconnected",
            "name": "GoPro 7594"
        }
    ],
    "command": "getAllCameras",
	"status_code": 0
}

Get the camera status

This command gets general and status information of the camera(s). The status code can be 0 (ok) or -3 (camera with the given name was not found).

Request:
{
	"command": "cameraStatus",
	"cameras": ["GP123456"]
}

Note: Leave the "cameras" variable empty if you want to query the status of all cameras.

Response:
{
	"command": "cameraStatus",
	"cameras":
	[
		{
			"name": "GP123456",
			"model": "Hero 8",
			"bluetooth_status": "connected",
			"wifi_ssid": "GP123456",
			"wifi_password": "password1234",
			"connection_type": "bluetooth",
			"camera_recording": false,
			"live_streaming": "idle",
			"preset_id": 1234,
			"camera_mode": 1000,
			"camera_submode": 0,
			"recording_time": "00:14",
			"remaining_photos": 102,
			"remaining_space": 1000000,
			"remaining_recording_time": 1324324,
			"charger_attached": true,
			"battery_level": 99
		}
	],
	"status_code": 0
}			

The connection_type can be "bluetooth", "wifi", or "usb".


Update current WiFi information

This command queries the currently connected WiFi name from the system. The result can later be read using the getCurrentWiFiSSID command. The status code is always 0 (ok).

Request:
{
	"command": "queryCurrentWiFiSSIDAsync"
}
Response:
{
	"command": "queryCurrentWiFiSSIDAsync",
	"status_code": 0
}

Get current WiFi SSID

This command returns the WiFi name from the last queryCurrentWiFiSSIDAsync query. Possible status_code values are 0 (ok) and -4 (no WiFi credentials are available. This is usually the case if you have not called queryCurrentWiFiSSIDAsync() first.).

Request:
{
	"command": "getCurrentWiFiSSID"
}
Response:
{
	"message": "Optional error message.",
	"command": "getCurrentWiFiSSID",
	"ssid": "wifi_name",
	"last_updated": "2020-01-20T14:11:25",
	"status_code": 0
}

Connect to a WiFi network

This command connects to the WiFi network using the given credentials. The "adapter" parameter contains an optional WiFi interface name. The status code is always 0 (ok).

Request:
{
	"command": "connectToWiFiAsync",
	"ssid": "GP123456",
	"password": "password1234",
	"adapter": ""
}
Response:
{
	"command": "connectToWiFiAsync",
	"status_code": 0
}

Connect to a camera WiFi network

This command connects to the given camera's WiFi network. The status code can be 0 (ok), -3 (camera with the given name was not found), or -5 (camera is not connected).

Request:
{
	"command": "connectToCameraWiFiAsync",
	"camera": "GP123456"
}
Response:
{
	"command": "connectToCameraWiFiAsync",
	"status_code": 0
}

Query the media list

This command loads the list of media files from the camera. The command requires an active WiFi connection to the camera (e.g. using connectToCameraWiFiAsync). The result can be later read with the getMediaList command. The status code can be 0 (ok), -6 (another media query is already running), -3 (camera not found), or -5 (camera not connected). The "force" parameter forces to send a new media query to the camera, even if a query is still active. If "lrv" is set to true then LRV files are returned instead of MP4 (Warning: depending on the video mode, the LRV file might not be available on the camera).

Request:
{
	"command": "queryMediaListAsync",
	"camera": "GP123456",
	"force": false,
	"lrv": false
}
Response:
{
	"command": "queryMediaListAsync",
	"message": "Optional error message.",
	"status_code": 0
}

Get the status of the last media query

This command gets the status of the last queryMediaListAsync call. Possible status values are idle, error, and busy ("busy" means that the media information is currently downloaded from the camera). The status code can be 0 (ok), -3 (camera with the given name was not found), or -6 (the media query is still running). If the "camera" field is empty then a random camera is selected (due to compatibility reasons).

Request:
{
	"command": "getMediaQueryStatus",
	"camera": "GP123456"
}
Response:
{
	"command": "getMediaQueryStatus",
	"status": "idle",
	"status_code": 0
}

Get media list

This command returns the last media list for the given cameras queried by queryMediaListAsync command. The status code can be 0 (ok) or -3 (camera with the given name was not found).

Request:
{
	"command": "getMediaList",
	"camera": "GP123456"
}
Response:
{
	"command": "getMediaList",
	"camera": "GP123456",
	"media": 
	[
		{
			"filename": "image.jpg",
			"url": "http://10.5.5.9/DCIM/image.jpg",
			"date": "2020-01-20T14:11:25",
			"size": 123000023
		}
	],
	"status_code": 0
}

Delete media from the camera

This command deletes media files from the camera. The command requires an active WiFi connection to the camera (e.g. using connectToCameraWiFiAsync). The status code can be 0 (ok), -3 (camera with the given name was not found), or, -5 (camera not connected).

Request:
{
	"command": "deleteMediaAsync",
	"camera": "GP123456",
	"media":
	[
		"100GOPRO/GOPR0573.JPG", "100GOPRO/GOPR0574.JPG"
	]
}
Response:
{
	"command": "deleteMediaAsync",
	"message": "Optional error message.",
	"status_code": 0
}

Send camera command

This command sends a specific command to the camera. The following commands are available:

  • connectToCamera: Connects to the camera(s) via Bluetooth.
  • disconnectFromCamera: Disconnects from the camera(s).
  • sleepCamera: Sends the camera(s) into sleeping state.
  • startRecording: Starts recording.
  • stopRecording: Stops recording.
  • tagMoment: Tags the moment.
  • enableWiFi: Enables the camera(s)' WiFi (without connecting to the WiFi!).
  • disableWiFi: Disables the camera(s)' WiFi.
  • startLivePreviewMode: Starts the live preview mode on one camera (this requires an active WiFi connection to the camera!). The live preview video can then be streamed with ffmpeg or other tools.
  • stopLivePreviewMode: Stops the live preview mode on one camera (this requires an active WiFi connection to the camera!).

The status code can be 0 (ok), -2 (unkown command), -3 (camera with the given name was not found), or, -5 (camera not connected; not applicable for "connectToCamera" and "disconnectFromCamera").

Request:
{
	"command": "sendCameraCommand",
	"cameras": ["GP123456"],
	"cameraCommand": "startRecording"
}
Response:
{
	"command": "sendCameraCommand",
	"message": "Optional error message.",
	"status_code": 0
}

Get a list of camera modes and presets

This command returns a list of supported camera modes, sub-modes (pre Hero 8), and presets (Hero 8 and newer). For Hero 7 and older models the old_group_key key should be used as the group key. The status code can be 0 (ok), -3 (camera with the given name was not found), or, -5 (camera not connected).

Request:
{
	"command": "getCameraModes",
	"camera": "GP123456"
}
Response:
{
	"command": "getCameraModes",
	"camera": "GP123456",
	"modes": 
	[
		{
			"name": "VIDEO",
			"key": 1000,
			"submodes": 
			[
				{
					"name": "looping",
					"key": 1,
					"old_group_key": 0
				}
			],
			"presets": 
			[
				{
					"name": "Default",
					"key": 0,
					"old_group_key": 0
				}
			]
		}
	],
	"status_code": 0
}

Set the camera mode group

This command sets the camera mode group (e.g. video, photo, ...). The status code can be 0 (ok), -3 (camera with the given name was not found), or, -5 (camera not connected).

Request:
{
	"command": "setCameraMode",
	"camera": "GP123456",
	"mode_key": 1000
}
Response:
{
	"command": "setCameraMode",
	"camera": "GP123456",
	"message": "Optional error message.",
	"status_code": 0
}

Set the camera sub-mode

This command sets the camera sub-mode (e.g. looping, burst, ...). This command is only intended for Hero 7 and older models. The status code can be 0 (ok), -3 (camera with the given name was not found), or, -5 (camera not connected).

Request:
{
	"command": "setCameraSubMode",
	"camera": "GP123456",
	"submode_key": 0
}
Response:
{
	"command": "setCameraSubMode",
	"camera": "GP123456",
	"message": "Optional error message.",
	"status_code": 0
}

Set the camera preset

This command sets the camera preset (e.g. standard, activity, ...). This command is only intended for Hero 8 and newer models. The status code can be 0 (ok), -3 (camera with the given name was not found), or, -5 (camera not connected).

Request:
{
	"command": "setCameraPreset",
	"camera": "GP123456",
	"preset_key": 0
}
Response:
{
	"command": "setCameraPreset",
	"camera": "GP123456",
	"message": "Optional error message.",
	"status_code": 0
}

Get a list of available settings

This command returns a list of all currently available settings for the given camera. Note: The available settings change dynamically. The status code can be 0 (ok), -3 (camera with the given name was not found), or, -5 (camera not connected).

Request:
{
	"command": "getCameraSettings",
	"camera": "GP123456"
}
Response:
{
	"command": "getCameraSettings",
	"camera": "GP123456",
	"settings": 
	[
		{
			"name": "Resolution",
			"key": "22",
			"values": 
			[
				{
					"name": "1080p",
					"value": "0"
				},
				{
					"name": "720p",
					"value": "1"
				}
			]
		}
	],
	"status_code": 0
}

Change a camera setting value

This command changes settings on the camera. The status code can be 0 (ok), -3 (camera with the given name was not found), or, -5 (camera not connected).

Request:
{
	"command": "setCameraSetting",
	"camera": "GP123456",
	"setting_key": 22,
	"setting_value": 1
}
Response:
{
	"command": "setCameraSetting",
	"camera": "GP123456",
	"message": "Optional error message.",
	"status_code": 0
}

Start a script (since 1.6.4)

This command starts a script in the app and returns a unique script ID. It is possible to run multiple scripts in parallel. Note: The POST data contains the raw script code.

Request:
http://127.0.0.1:801/startScript
with this POST data:
// script code
Response:
{
	"command": "startScript",
	"script_id": 1234,
	"message": "Optional error message.",
	"status_code": 0
}

Stop a script

This command stops a script and removes it from the list of active scripts. The status code can be 0 (ok) or -7 (the script ID was not found).

Request:
{
	"command": "stopScript",
	"script_id": 1234
}
Response:
{
	"command": "stopScript",
	"script_id": 1234,
	"message": "Optional error message.",
	"status_code": 0
}

Get the live output of a script

This command returns the (debug) output of a script. The status code can be 0 (ok) or -7 (the script ID was not found).

Request:
{
	"command": "getScriptOutput",
	"script_id": 1234
}
Response:
{
	"command": "getScriptOutput",
	"script_id": 1234,
	"output": "status messages produced by the script",
	"message": "Optional error message.",
	"status_code": 0
}

Get a list of active scripts

This command returns a list of active scripts.

Request:
{
	"command": "getActiveScriptsList"
}
Response:
{
	"command": "getActiveScriptsList",
	"active_scripts": [1234, 1235],
	"status_code": 0
}