Skip to content

ywatanabe-dev/fake-theta

 
 

Repository files navigation

Fake THETA

Fake THETA is a RICOH THETA Web APIs simulator. It can be used for testing applications that work with THETA Web APIs. You can switch from which model you get the responses of web APIs. Fake THETA supports the following models of THETA:

  • THETA X
  • THETA Z1

Features

Fake THETA provides fake responses (fixed values) for the following Web APIs. See THETA API Specifications for details of each API.

Please note that Fake THETA returns a JPEG file with content-type:image/jpeg while the actual THETA device returns MotionJPEG frames with content-type:multipart/x-mixed-replace when calling camera.getLivePreview API.

Protocols

Commands

Usage

Fake THETA is implemented as vercel serverless functions deployed on "fake-theta.vercel.app". You can get the fake responses of RICOH THETA web APIs by setting https://fake-theta.vercel.app as an endpoint.

Note: "fake-theta.vercel.app" is an endpoint deployed from the master branch of this repository, so its behavior may change when the master branch is updated.

In order to specify the model, you can add a header parameter emulating-theta-model when sending a Request. If nothing is specified, Fake THETA behaves as THETA X.

Fake THETA only supports required parameters for each command execution. For example, for the listFiles command, Fake THETA only reads the values of fileType, entryCount, and maxThumbSize. Non-required parameters are ignored in the current implementation (treated as if they were never entered).

Examples

  • Get /osc/info response (THETA X)

    curl -H "emulating-theta-model:x" https://fake-theta.vercel.app/osc/info
    {
      "api": [
        "/osc/info",
        "/osc/state",
        "/osc/checkForUpdates",
        "/osc/commands/execute",
        "/osc/commands/status"
      ],
      "apiLevel": [2],
      "endpoints": { "httpPort": 80, "httpUpdatesPort": 80 },
      "firmwareVersion": "1.41.0",
      "gps": false,
      "gyro": false,
      "manufacturer": "Ricoh Company, Ltd.",
      "model": "RICOH THETA X",
      "serialNumber": "10100001",
      "supportUrl": "https://theta360.com/en/support/",
      "uptime": 67,
      "_wlanMacAddress": "00:45:78:bc:45:67"
    }
  • Get camera.takePicture response (THETA X)

    curl -X POST -H "emulating-theta-model:x" \
    -H "Content-Type: application/json" \
    -d "{\"name\": \"camera.takePicture\"}" https://fake-theta.vercel.app/osc/commands/execute
    {
      "id": "10",
      "progress": { "completion": 0 },
      "name": "camera.takePicture",
      "state": "inProgress"
    }
  • Get camera.getOptions response (THETA Z1)

    curl -X POST  -H "emulating-theta-model:z1" \
    -H "Content-Type: application/json" \
    -d "{\"name\": \"camera.getOptions\", \"parameters\": {\"optionNames\": [\"fileFormatSupport\"]}}" \
    https://fake-theta.vercel.app/osc/commands/execute
    {
      "name": "camera.getOptions",
      "results": {
        "options": {
          "fileFormatSupport": [
            { "height": 3360, "type": "jpeg", "width": 6720 },
            { "height": 3360, "type": "raw+", "width": 6720 }
          ]
        }
      },
      "state": "done"
    }
  • Get JPG file in the camera

    curl https://fake-theta.vercel.app/files/150100525831424d42075b53ce68c300/100RICOH/R0010015.JPG \
    > ~/R0010015.JPG

TODO

  • Support dynamic responses simulation according to internal states of the camera
  • Support completely-reproduced error responses for each model
  • Add parameter validation of APIs
  • Support non-required parameters for each command

License

MIT License

About

RICOH THETA Web API simulator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.9%
  • Shell 0.1%