HowTo: Develop 360 Image Desktop Apps with JavaScript and RICOH THETA

this one is more recent.

Example with GET

import fetch from 'node-fetch';

// basic info with get
const response = await fetch('http://192.168.1.1/osc/info');
const body = await response.text();

console.log(body);

Response

$ node javascript-test.js 
{"api":["/osc/info","/osc/state","/osc/checkForUpdates","/osc/commands/execute","/osc/commands/status"],"apiLevel":[2],"_bluetoothMacAddress":"58:38:79:03:0C:47","endpoints":{"httpPort":80,"httpUpdatesPort":80},"firmwareVersion":"2.01.0","gps":false,"gyro":true,"manufacturer":"RICOH","model":"RICOH THETA Z1","serialNumber":"10010104","supportUrl":"https://theta360.com/en/support/","uptime":16258,"_wlanMacAddress":"58:38:79:03:17:06"}

Example with POST

Same code as above. Just change the line with the request.

// camera state with POST
const response = await fetch('http://192.168.1.1/osc/state', 
  {method: 'POST', body: {}});

response

$ node javascript-test.js 
{"fingerprint":"FIG_0015","state":{"_apiVersion":2,"batteryLevel":0.99,"_batteryState":"charged","_cameraError":["COMPASS_CALIBRATION"],"_captureStatus":"idle","_capturedPictures":0,"_compositeShootingElapsedTime":0,"_function":"normal","_latestFileUrl":"","_mySettingChanged":false,"_pluginRunning":false,"_pluginWebServer":true,"_recordableTime":0,"_recordedTime":0,"storageUri":"http://192.168.1.1/files/150100524436344d42013765da9bc400/"}}

Example POST with body

same as above with different response

  // example command
  const response = await fetch('http://192.168.1.1/osc/commands/execute', 
  {method: 'POST', body: 
  JSON.stringify({
    name: 'camera.takePicture'
  }),
  headers: {'Content-type': 'application/json; charset=UTF-8'},
});  

Example with POST, body and parameters

// example to set option
const response = await fetch('http://192.168.1.1/osc/commands/execute', 
{method: 'POST', body: 
JSON.stringify({
  name: 'camera.setOptions',
  parameters: {
    options: {
      _filter : 'hdr'
    }
  }
}),
headers: {'Content-type': 'application/json; charset=UTF-8'},
});  

response

$ node javascript-test.js 
{"name":"camera.setOptions","state":"done"}

get multiple options from camera

// example to get options
const response = await fetch('http://192.168.1.1/osc/commands/execute', 
{method: 'POST', body: 
JSON.stringify({
  name: 'camera.getOptions',
  parameters: {
    optionNames: [
      '_filter',
      'sleepDelay',
      'offDelay',
      'videoStitching',
      '_visibilityReduction',
    ]
  }
}),
headers: {'Content-type': 'application/json; charset=UTF-8'},
});  

response

$ node javascript-test.js 
{"name":"camera.getOptions","results":{"options":{"_filter":"hdr","offDelay":0,"sleepDelay":65535,"videoStitching":"none","_visibilityReduction":"OFF"}},"state":"done"}