RICOH THETA API Examples

RICOH THETA API Examples

The new RICOH THETA API Introduction video shows basic development concepts by showing how to access the API with three different techniques.

  1. curl HTTP requests on the command line
  2. HTTP testing tool Insomnia (similar to Postman)
  3. Testing the HTTP requests inside a barebones mobile app

After reading the RICOH THETA API Getting Started article, you are likely already testing the camera API.

Sharing RICOH THETA API Tests with curl

Most people share tests as curl scripts. This is easy because curl usually exists on MacOS, Windows and Linux.

Using curl to test the camera info API

In addition to HTTP GET requests, you can also use curl to send HTTP POST requests, either with a body or without.

Using curl with a POST HTTP request to the RICOH THETA API

Using Specialized API Testers like Insomnia and Postman

Although curl is ubiquitous and easy to send basic commands, it does get increasingly difficult to test multiple commands in sequence and to keep a series of tests saved.

After testing out curl, I recommend using a specialized HTTP API testing tool.

Using Insomnia to test the osc/info API command

The HTTP response will be nicely formatted.

response format from Insomnia

The image and video files on the camera are accessible with URLs. You can click on the URL in the Insomnia response window to see the picture on the camera that you took for testing.

last image URL from the osc/state command
Image automatically opens in Firefox when the link in the response window is clicked

Advantage of Testing the RICOH THETA API in Barebones Mobile Apps

Mobile apps have several advantages for testing.

  1. Using the actual Wi-Fi chipset in iPhones and Pixel physical device phones is a better way to test the camera to device connection. The Wi-Fi chipset in your Windows or Mac computer may exhibit different behavior when connecting to the RICOH THETA camera as a Wi-Fi hotspot. If your target device is a something like a Pixel 4, then it is better to test the application on a physical device Pixel 4 instead of a Windows Android Virtual Device.
  2. It’s easier to solve network security and routing behavior problems if you’re using the physical device. For example, turning on mobile data and bluetooth on the physical device may change how routing is done to an HTTP endpoint at 192.168.1.1 if the endpoint is not connected to the Internet. Another issue is that sending data to http and not to https may be blocked in the default behavior of iOS and Android. You may need to set up an exception rule in the mobile app build configuration.
  3. It’s easier to test a sequence of real-world commands. For example, you can configure a startCapture button to set the camera fileFormat settings. It can then set the captureMode to video, and finally execute startCapture. There may also be timing considerations such as waiting 500ms between changing the captureMode and running startCapture.

Download Barebones Apps for RICOH THETA API Mobile App Testing

To make it easy to test different scenarios, we’ve built 4 different barebones apps.

  1. RICOH THETA API Camera Connection – Camera as HTTP endpoint. HTTP GET and POST request format. Header format. POST request with body
  2. Using RICOH THETA API Response to Update App Screen – Camera response is JSON. Encode into object for the language you are using to extract information such as battery level. Update mobile app interface when camera response is received.
  3. RICOH THETA API App State Management with BLoC – List thumbnails at reduced size for network efficiency. Show 360 image with navigation. Set 8K 2fps and 8K 5fps video. Switch between image and video mode. Extract URL of files on camera using listFiles. Use Business LOgic Components to separate logic from GUI and application state.
  4. THETA X Multi-Bloc – simple app will show multiple screens with one Bloc attached to each screen.

Summary of Testing Workflows

It may be easier to share your API test as a curl script if you share the test in the theta360.guide forum or as an email attachment. However, for daily testing, I find it easier to use a specialized API testing tool like Insomnia or Postman. I also like to build simple mobile apps with a small feature set to test behavior on physical mobile phones.

Start the discussion at community.theta360.guide