RICOH THETA API Getting Started

Originally published at: RICOH THETA API Getting Started - RICOH THETA Developer Community

Get started with the RICOH THETA API at start.theta360.guide.

RICOH THETA Development Getting Started Introduction

Companies like Zillow, Matterport, and OpenSpace use the RICOH THETA API to dramatically reduce the time to take pictures and create virtual product and site tours.

The boom in development of RICOH THETA API applications is driven both by the rapid move to virtual buying and inspection workflows as well as the ease-of-use of the API. Most developers are already familiar with HTTP API requests. The RICOH THETA API is simple to access.

HTTP request to RICOH THETA using Wi-Fi.

curl 192.168.1.1/osc/info

HTTP response edited for conciseness.

{..."firmwareVersion":"1.10.1","manufacturer":"Ricoh Company, Ltd.","model":"RICOH THETA X","serialNumber":"14010001","_wlanMacAddress":"0C:8B:FD:2F:05:7B"}

RICOH THETA API Camera Connection

Get started sending API commands with our HTTP Camera Connection tutorial.

View the simple code on GitHub.

The camera functions as a Wi-Fi hotspot.

Once connected with Wi-Fi, the camera is at 192.168.1.1.

You send GET and POST HTTP requests to the camera.

Take Picture with RICOH THETA API

To take a picture, send an HTTP POST command with a JSON-encoded body.

Body:

{'name': 'camera.takePicture'};

Endpoint:

'http://192.168.1.1/osc/commands/execute'

The pictures on the camera are accessible with image URLs. As the camera takes 360 pictures, you will likely be in the pictures for your test shots. Remember to smile 🙂

RICOH THETA API Headers

Most the RICOH THETA API commands will fail without the HTTP headers.

You should pass the following header with your HTTP request.

 'Content-Type': 'application/json;charset=utf-8'

Here’s an example of using the header.

var header = {
    'Content-Type': 'application/json;charset=utf-8'}
var url = Uri.parse('http://192.168.1.1/osc/state');
var response = await http.post(url, headers: header);

RICOH THETA API Request Body Format

The body must be encoded as JSON. In this example, we are using a Dart library with a prebuilt method called jsonEncode. In the first example for taking a picture, the endpoint is first converted from a string to a URL, then the body is encoded as JSON. The example with the new steps is shown below.

var url = Uri.parse('http://192.168.1.1/osc/commands/execute');
var header = {
    'Content-Type': 'application/json;charset=utf-8'}
var bodyMap = {'name': 'camera.takePicture'};
var bodyJson = jsonEncode(bodyMap);
  var response = await http.post(url, headers: header, body: bodyJson);

RICOH THETA API Response Body Format

After you send a request to the camera, your application will receive a response. The response from the RICOH THETA API will be in JSON format. To use JSON in your application, you may need to convert it into a local format such as a map or a dictionary.

In the snippet below, we can get the battery level from the osc/state command.

var thetaState = jsonDecode(response.body);
var batteryLevel = thetaState['state']['batteryLevel'];

RICOH THETA API Next Steps

Using RICOH THETA API Response to Update App Screen

RICOH THETA API App State Management with BLoC