Enjox Toy HTTP SDK Documentation

Overview

Third-party apps can use the Enjox HTTP SDK to gain control capabilities over the toys.

The HTTP SDK functionality is provided by the EnjoxRemote App. In this case, the EnjoxRemote App acts as a Bluetooth ↔ HTTP proxy, allowing you to easily control all toys on the same phone (or Wi-Fi network) through the standard HTTP protocol. Users must first launch the EnjoxRemote App before launching your app to use the HTTP SDK.

Enjox Toy HTTP SDK Communication Diagram

Architecture: Your App communicates with EnjoxRemote App via HTTP SDK, and EnjoxRemote App communicates with Enjox Toys via Bluetooth.

Test Page >>

Note: When accessing via Wi-Fi network, replace 127.0.0.1 with the IP address of the device running the EnjoxRemote App. The default port is 8089.

Invocation Method

http://127.0.0.1:8089/{command}?param=value[&token=xxx]

Request Method

GET, POST

Request Parameters

Parameter Description Values
command Command vibrate, rotate, preset, pattern
param Parameters Varies depending on the command
token Token Fixed value: 6b9a21fb055343f8b10113a1b78b7229 (currently fixed, may be required in future versions)

Response Format

{"ret": 0, "data": 0}
ret data Description
0 - Success
1 10 Unknown error
1 11 Toy not connected
1 12 Toy battery low

Simple API

Vibrate Toy

http://127.0.0.1:8089/vibrate?speed=num&time=msec

Function

Vibrate the toy for msec milliseconds

Request Method

GET

Request Parameters

Parameter Description Values
speed Speed 0-100, 0 to stop, 100 for maximum intensity
time Time Milliseconds

Example

http://127.0.0.1:8089/vibrate?speed=20&time=1000

Limitation

Minimum interval between two commands is 100ms

Rotate Toy

http://127.0.0.1:8089/rotate?speed=num&time=msec

Function

Rotate the toy for msec milliseconds

Request Method

GET

Request Parameters

Parameter Description Values
speed Speed 0-100, 0 to stop, 100 for maximum intensity
time Time Milliseconds

Example

http://127.0.0.1:8089/rotate?speed=20&time=1000

Stop Toy

http://127.0.0.1:8089/stop

Function

Stop all toy actions

Request Method

GET

Request Parameters

None

Pattern API

Preset Patterns

http://127.0.0.1:8089/preset?id=num

Function

Vibrate the toy using predefined patterns

Request Method

GET

Request Parameters

Parameter Description Values
id Pattern ID 1 Pulse, 2 Wave, 3 Firework, 4 Earthquake

Example

http://127.0.0.1:8089/preset?id=1

Notes

The toy can be stopped at any time using the Simple API. If not stopped, the toy will continue to repeat the pattern indefinitely until the battery is depleted.

Pattern Stream

http://127.0.0.1:8089/pattern

Function

Send a series of commands to the toy

Request Method

POST

Request Parameters

Parameter Description Values
data Pattern stream Pattern stream string (in request body)

Example

http://127.0.0.1:8089/pattern

Request Body

Content-Type: application/x-www-form-urlencoded

data=V:1;F:v,r;S:100;#0,0;2,0;4,3;5,5;6,6;

Notes

Pattern streams can be custom-written or recorded in Enjox Remote by sliding your finger.

Pattern Stream Format

A pattern stream consists of a pattern header and pattern data, separated by #. The pattern header description is shown in the table below. Pattern data is a string of comma-separated number pairs separated by semicolons, with each pair corresponding to the action types in the pattern header (e.g., for F=v,r, each pair contains values for vibrate and rotate).

Keyword Content Description
V 1 Version number
F v,r Action types: v = vibrate, r = rotate, p = contract
S 100 Time interval in milliseconds

Our site uses cookies. By continuing to use our site, you agree to the use of cookies. For more information about the use of cookies on our website, please see our Cookie Policy.