THETA Web API Learning

Hello. I’m just beginning to learn how to use the Web API with a Theta V camera. I was able to use the POST command with /osc/state, but have been unable to get it to work with any request using /osc/commands/execute. I’ve been using Python with the requests library to sent the requests.

import requests
url = “http://192.168.1.1/osc/commands/execute
pload = {
“name”: “camera.getOptions”,
“parameters”: {
“optionNames”: [
“fileFormat”,
“fileFormatSupport”
]
}
}
r = requests.post(url, data = pload)

print (r.text)

Here is a sample of my code. It returns an error of “Command executed is unknown.” I’ve been trying to look around for information, but I haven’t been able to determine what may be the source of my error. Any help would be appreciated.

Hello,

You need some extra parameters and you must use json data format.
Here is an example in python

AUTH = HTTPDigestAuth(‘THETAYL00108440’, ‘00108440’) #needed for wifi client mode, change with your serial number
HEADERS = {‘content-type’: ‘application/json’}
timeout is not mandatory
IPADRESS is 192.168.1.1 in WiFi AP mode

	url = "".join(("http://", IPADRESS, ":80/osc/commands/execute"))	  
	body = json.dumps({"name": "camera.setOptions", "parameters": { "options": {
						"captureMode": "video", "sleepDelay": 1200, "offDelay": 600, "videoStitching" : "none",
							"_microphoneChannel": "1ch", "_gain" : "mute",  "_shutterVolume" : 100,
							"previewFormat" : {"width": 1024, "height": 512, "framerate": 8}}}})
	try:
		req = requests.post(url, data=body,headers=HEADERS,auth=AUTH,timeout=3)
	except Exception:
		pass

Hugues

Some examples with requests here

Old examples with older API