Standard Solutions

Standard Solutions

If you integrate a Standard Solution, your users must use Lovense Remote to pair their toys. Lovense Remote is available on Google Play and the App Store.

Lovense Remote App

We offer two different ways of data forwarding solution

If you are a web application developer, We recommend that you use the Standard JDK directly, it is a javascript implementation of the Standard Socket API solution.

Standard API

This API allows any application to access its users Lovense toys from the developer side.

Here is a sample demo for your reference.

Step 1: Configure the developer dashboard

Go to the developer dashboardopen in new window and set your Callback URL.

Set your Callback URL

Step 2: Find your user's toy(s)

  1. Get your developer token from the Lovense developer dashboard.

  2. Your server calls Lovense server's API (use POST request)

    For example:

    String url= "https://api.lovense-api.com/api/lan/getQrCode";
    Map<String, String> requestParameter = new HashMap<String, String>();
    //TODO initialize your parameters:
    requestParameter.put("token", "{Lovense developer token}");
    requestParameter.put("uid", "{user ID on your website}");
    requestParameter.put("uname", "{user nickname on your website}");
    requestParameter.put("utoken", "{Encrypted user token on your application. This is a security consideration, to avoid others stealing control of the toy.}");
    requestParameter.put("v", 2);
    HttpPost httpPost = new HttpPost(url);
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    if (requestParameter != null && !requestParameter.isEmpty()) {
      Set<String> keys = requestParameter.keySet();
      for (String key : keys) {
        nameValuePairs.add(new BasicNameValuePair(key, requestParameter.get(key)));
      }
    }
    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    const result = await axios.post(
      "https://api.lovense-api.com/api/lan/getQrCode",
      {
        token: "your developer token", // Lovense developer token
        uid: "11111", // user ID on your website
        uname: "user name", // user nickname on your website
        utoken: md5(uid + "salt"), // This is for your own verification purposes. We suggest you to generate a unique token/secret for each user. This allows you to verify the user and avoid others faking the calls.
        v: 2,
      }
    )
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10

    You will get:

    {
       code: 0
       message: "Success"
       result: true
       data: {
         "qr": "https://test2.lovense.com/UploadFiles/qr/20220106/xxx.jpg", // QR code picture
         "code": "xxxxxx"
       }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
  3. Once the user scans the QR code with the Lovense Remote app, the app will invoke the Callback URL you've provided in the developer dashboard. The Lovense server is no longer required. All communications will go from the app to your server directly.

    The Lovense Remote app will send the following POST to your server:

    {
      "uid": "xxx",
      "appVersion": "4.0.3",
      "toys": {
        "xxxx": {
          "nickName": "",
          "name": "max",
          "id": "xxxx",
          "status": 1
        }
      },
      "wssPort": "34568",
      "httpPort": "34567",
      "wsPort": "34567",
      "appType": "remote",
      "domain": "192-168-1-44.lovense.club",
      "utoken": "xxxxxx",
      "httpsPort": "34568",
      "version": "101",
      "platform": "android"
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21

Step 3: Command the toy(s)

Note: iOS Remote 5.1.4+, Android Remote 5.1.1+, or PC Remote 1.5.8+ is required.

By local application

If the user's device is in the same LAN environment, a POST request to Lovense Remote can trigger a toy response. In this case, your server and Lovense's server are not required.

If the user uses the mobile version of Lovense Remote app, the domain and httpsPort are accessed from the callback information. If the user uses Lovense Remote for PC, the domain is 127-0-0-1.lovense.club, and the httpsPort is 30010

With the same command line, different parameters will lead to different results as below.

  • GetToys Request

    Get the user's toy(s) information.

    API URL: https://{domain}:{httpsPort}/command

    Request Protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Response Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    commandType of requestString/yes

    Request Example:

    {
      "command": "GetToys"
    }
    
    1
    2
    3

    Response Example:

    {
      "code": 200,
      "data": {
        "toys": "{  \"fc9f37e96593\" : {    \"id\" : \"fc9f37e96593\",    \"status\" : \"1\",    \"version\" : \"\",    \"name\" : \"nora\",    \"battery\" : 100,    \"nickName\" : \"\"  }}",
        "platform": "ios",
        "appType": "remote"
      },
      "type": "OK"
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
  • GetToyName Request

    Get the user's toy(s) name.

    API URL: https://{domain}:{httpsPort}/command

    Request Protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Response Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    commandType of requestString/yes

    Request Example:

    {
      "command": "GetToyName"
    }
    
    1
    2
    3

    Response Example:

    {
      "code": 200,
      "data": [
        "Domi",
        "Nora"
      ],
      "type": "OK"
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
  • Function Request

    API URL: https://{domain}:{httpsPort}/command

    Request Protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Response Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    commandType of requestString/yes
    actionControl the function and strength of the toystringActions can be Vibrate, Rotate, Pump, Thrusting, Fingering, Suction or Stop. Use All to make all functions respond. Use Stop to stop the toy’s response.
    Range:
    Vibrate:0 ~ 20
    Rotate: 0~20
    Pump:0~3
    Thrusting:0~20
    Fingering:0~20
    Suction:0~20
    All:0~20
    yes
    timeSecTotal running timedouble0 = indefinite length
    Otherwise, running time should be greater than 1.
    yes
    loopRunningSecRunning timedoubleShould be greater than 1no
    loopPauseSecSuspend timedoubleShould be greater than 1no
    toyToy IDstringIf you don’t include this, it will be applied to all toysno
    stopPreviousStop all previous commands and execute current commandsintDefault: 1, If set to 0 , it will not stop the previous command.no
    apiVerThe version of the requestintAlways use 1yes

    The stopPrevious parameter is available in the following versions: Android Remote 5.2.2, iOS Remote 5.4.4, PC Remote 1.6.3.

    Request Example:

    // Vibrate toy ff922f7fd345 at 16th strength, run 9 seconds then suspend 4 seconds. It will be looped. Total running time is 20 seconds.
    {
      "command": "Function",
      "action": "Vibrate:16",
      "timeSec": 20,
      "loopRunningSec": 9,
      "loopPauseSec": 4,
      "toy": "ff922f7fd345",
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    // Vibrate 9 seconds at 2nd strength
    // Rotate toys 9 seconds at 3rd strength
    // Pump all toys 9 seconds at 4th strength
    // For all toys, it will run 9 seconds then suspend 4 seconds. It will be looped. Total running time is 20 seconds.
    {
      "command": "Function",
      "action": "Vibrate:2,Rotate:3,Pump:3",
      "timeSec": 20,
      "loopRunningSec": 9,
      "loopPauseSec": 4,
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    // Vibrate 9 seconds at 2nd strength
    // The rest of the functions respond to 10th strength 9 seconds
    {
      "command": "Function",
      "action": "Vibrate:2,All:10",
      "timeSec": 20,
      "loopRunningSec": 9,
      "loopPauseSec": 4,
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    // Stop all toys
    {
      "command": "Function",
      "action": "Stop",
      "timeSec": 0,
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
  • Pattern Request

    If you want to change the way the toy responds very frequently you can use a pattern request. To avoid network pressure and obtain a stable response, use the commands below to send your predefined patterns at once.

    API URL: https://{domain}:{httpsPort}/command

    Request protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Response Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    commandType of requestString/yes
    rule"V:1;F:v,r,p,t,f,s;S:1000#"
    V:1; Protocol version, this is static;
    F:v,r,p,t,f,s; Features: v is vibrate, r is rotate, p is pump, t is thrusting, f is fingering, s is suction, this should match the strength below. F:; Leave blank to make all functions respond;
    S:1000; Intervals in Milliseconds, should be greater than 100.
    stringThe strength of r and p will automatically correspond to v.yes
    strengthThe pattern
    For example: 20;20;5;20;10
    stringNo more than 50 parameters. Use semicolon ; to separate every strength.yes
    timeSecTotal running timedouble0 = indefinite length
    Otherwise, running time should be greater than 1.
    yes
    toyToy IDstringIf you don’t include this, it will apply to all toysno
    apiVerThe version of the requestintAlways use 2yes

    Request Example:

    // Vibrate the toy as defined. The interval between changes is 1 second. Total running time is 9 seconds.
    {
      "command": "Pattern",
      "rule": "V:1;F:v;S:1000#",
      "strength": "20;20;5;20;10",
      "timeSec": 9,
      "toy": "ff922f7fd345",
      "apiVer": 2
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    // Vibrate the toys as defined. The interval between changes is 0.1 second. Total running time is 9 seconds.
    // If the toys include Nora or Max, they will automatically rotate or pump, you don't need to define it.
    {
      "command": "Pattern",
      "rule": "V:1;F:v,r,p;S:100#",
      "strength": "20;20;5;20;10",
      "timeSec": 9,
      "apiVer": 2
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
  • Preset Request

    API URL: https://{domain}:{httpsPort}/command

    Request protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Response Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    commandType of requestString/yes
    namePreset pattern namestringWe provide four preset patterns in the Lovense Remote app: pulse, wave, fireworks, earthquakeyes
    timeSecTotal running timedouble0 = indefinite length
    Otherwise, running time should be greater than 1.
    yes
    toyToy IDstringIf you don’t include this, it will be applied to all toysno
    apiVerThe version of the requestintAlways use 1yes

    Request Example:

    // Vibrate the toy with pulse pattern, the running time is 9 seconds.
    {
      "command": "Preset",
      "name": "pulse",
      "timeSec": 9,
      "toy": "ff922f7fd345",
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
    8

    Response Example:

    {
      "code": 200,
      "type": "ok"
    }
    
    1
    2
    3
    4

    Error Codes:

    CodeMessage
    500HTTP server not started or disabled
    400Invalid Command
    401Toy Not Found
    402Toy Not Connected
    403Toy Doesn't Support This Command
    404Invalid Parameter
    506Server Error. Restart Lovense Connect.
By server

If your application can’t establish a LAN connection to the user’s Lovense Remote app, you can use the Server API to connect the user’s toy.

⚠️ If you are using Lovense Remote for PC, you need to enter a code to establish connection. Use the code generated alongside the QR code in step 2 above.

pc-remote-code

  • Function Request

    API URL: https://api.lovense-api.com/api/lan/v2/command

    Request Protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Request Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    tokenYour developer tokenstringyes
    uidYour user’s IDstringTo send commands to multiple users at the same time, add all the user IDs separated by commas. The toy parameter below will be ignored and the commands will go to all user toys by default.yes
    commandType of requestString/yes
    actionControl the function and strength of the toystringActions can be Vibrate, Rotate, Pump, Thrusting, Fingering, Suction, or Stop. Use Stop to stop the toy’s response.
    Range:
    Vibrate:0 ~ 20
    Rotate: 0~20
    Pump:0~3
    Thrusting:0~20
    Fingering:0~20
    Suction:0~20
    yes
    timeSecTotal running timedouble0 = indefinite length
    Otherwise, running time should be greater than 1.
    yes
    loopRunningSecRunning timedoubleShould be greater than 1no
    loopPauseSecSuspend timedoubleShould be greater than 1no
    toyToy IDstringIf you don’t include this, it will be applied to all toysno
    stopPreviousStop all previous commands and execute current commandsintDefault: 1, If set to 0 , it will not stop the previous command.no
    apiVerThe version of the requestintAlways use 1yes

    The stopPrevious parameter is available in the following versions: Android Remote 5.2.2, iOS Remote 5.4.4, PC Remote 1.6.3.

    Request Example:

    // Vibrate toy ff922f7fd345 at 16th strength, run 9 seconds then suspend 4 seconds. It will be looped. Total running time is 20 seconds.
    {
      "token": "FE1TxWpTciAl4E2QfYEfPLvo2jf8V6WJWkLJtzLqv/nB2AMos9XuWzgQNrbXSi6n",
      "uid": "1132fsdfsd",
      "command": "Function",
      "action": "Vibrate:16",
      "timeSec": 20,
      "loopRunningSec": 9,
      "loopPauseSec": 4,
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    // Vibrate 9 seconds at 2nd strength
    // Rotate toys 9 seconds at 3rd strength
    // Pump all toys 9 seconds at 4th strength
    // For all toys, it will run 9 seconds then suspend 4 seconds. It will be looped. Total running time is 20 seconds.
    {
      "token": "FE1TxWpTciAl4E2QfYEfPLvo2jf8V6WJWkLJtzLqv/nB2AMos9XuWzgQNrbXSi6n",
      "uid": "1132fsdfsd",
      "command": "Function",
      "action": "Vibrate:2,Rotate:3,Pump:3",
      "timeSec": 20,
      "loopRunningSec": 9,
      "loopPauseSec": 4,
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
  • Pattern Request

    If you want to change the way the toy responds very frequently you can use a pattern request. To avoid network pressure and obtain a stable response, use the commands below to send your predefined patterns at once.

    API URL: https://api.lovense-api.com/api/lan/v2/command

    Request protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Response Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    tokenYour developer tokenstringyes
    uidYour user’s IDstringyes
    commandType of requestString/yes
    rule"V:1;F:v,r,p,t,f,s;S:1000#"
    V:1; Protocol version, this is static;
    F:v,r,p,t,f,s; Features: v is vibrate, r is rotate, p is pump, t is thrusting, f is fingering, s is suction, this should match the strength below;
    S:1000; Intervals in Milliseconds, should be greater than 100.
    stringThe strength of r and p will automatically correspond to v.yes
    strengthThe pattern
    For example: 20;20;5;20;10
    stringNo more than 50 parameters. Use semicolon ; to separate every strength.yes
    timeSecTotal running timedouble0 = indefinite length
    Otherwise, running time should be greater than 1.
    yes
    toyToy IDstringIf you don’t include this, it will apply to all toysno
    apiVerThe version of the requestintAlways use 2yes

    Request Example:

    // Vibrate the toy as defined. The interval between changes is 1 second. Total running time is 9 seconds.
    {
      "token": "FE1TxWpTciAl4E2QfYEfPLvo2jf8V6WJWkLJtzLqv/nB2AMos9XuWzgQNrbXSi6n",
      "uid": "1ads22adsf",
      "command": "Pattern",
      "rule": "V:1;F:v;S:1000#",
      "strength": "20;20;5;20;10",
      "timeSec": 9,
      "apiVer": 2
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    // Vibrate the toys as defined. The interval between changes is 0.1 second. Total running time is 9 seconds.
    // If the toys include Nora or Max, they will automatically rotate or pump, you don't need to define it.
    {
      "token": "FE1TxWpTciAl4E2QfYEfPLvo2jf8V6WJWkLJtzLqv/nB2AMos9XuWzgQNrbXSi6n",
      "uid": "1ads22adsf",
      "command": "Pattern",
      "rule": "V:1;F:v,r,p;S:100#",
      "strength": "20;20;5;20;10",
      "timeSec": 9,
      "apiVer": 2
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
  • Preset Request

    API URL: https://api.lovense-api.com/api/lan/v2/command

    Request protocol: HTTPS Request

    Method: POST

    Request Content Type: application/json

    Request Format: JSON

    Parameters:

    NameDescriptionTypeNoteRequired
    tokenYour developer tokenstringyes
    uidYour user’s IDstringyes
    commandType of requestString/yes
    namePreset pattern namestringWe provide four preset patterns in the Lovense Remote app: pulse, wave, fireworks, earthquakeyes
    timeSecTotal running timedouble0 = indefinite length
    Otherwise, running time should be greater than 1.
    yes
    toyToy IDstringIf you don’t include this, it will be applied to all toysno
    apiVerThe version of the requestintAlways use 1yes

    Request Example:

    // Vibrate the toy with pulse pattern, the running time is 9 seconds.
    {
      "token": "FE1TxWpTciAl4E2QfYEfPLvo2jf8V6WJWkLJtzLqv/nB2AMos9XuWzgQNrbXSi6n",
      "uid": "1adsf2323",
      "command": "Preset",
      "name": "pulse",
      "timeSec": 9,
      "apiVer": 1
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9

Response Example:

{
  "result": true,
  "code": 200,
  "message": "Success"
}
1
2
3
4
5

Server Error Codes:

CodeMessage
200Success
400Invalid command
404Invalid Parameter
501Invalid token
502You do not have permission to use this API
503Invalid User ID
507Lovense APP is offline

Game Mode

If you are developing an offline game or application, we recommend this solution.

  1. Enable Game Mode in Lovense Remote

Go to Me -> Settings -> Enable Game Mode switch -> Game Mode tab will open

game-mode

  1. Get the Local IP address

Users input the Local IP address from the Game Mode tab into your game. The machine running your game and Lovense Remote app must be on the same LAN.

  1. Command the user's toys

game-mode

Once the user has connected to your game, you can command the user's toy(s). Here is a link to the commands list (they're the same as the Standard API).

Standard Socket API

Work Flow

Step 1: Application for user authentication token

Use your developer token to apply for an authentication token for your users. You can get the developer token from developer dashboardopen in new window.

WARNING

For security reasons, the developer token should always be used on the server side. You should never use it in your JS code from the client side.

API URL: https://api.lovense-api.com/api/basicApi/getToken

Request Protocol: HTTPS Request

Method: POST

Request Content Type: application/json

Parameters:

NameDescriptionRequired
tokenDeveloper Tokenyes
uidUser ID on your applicationyes
unameUser nickname on your applicationno
utokenUser token from your website. This is for your own verification purposes, and we suggest you generate a unique token for each user. This allows you to verify the user and avoid faking the calls.no

Example:

String url= "https://api.lovense.com/api/basicApi/getToken";
Map<String, String> requestParameter = new HashMap<String, String>();
//TODO initialize your parameters:
requestParameter.put("token", "{Lovense developer token}");
requestParameter.put("uid", "{user ID on your application}");
requestParameter.put("uname", "{user nickname on your application}");
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
if (requestParameter != null && !requestParameter.isEmpty()) {
  Set<String> keys = requestParameter.keySet();
  for (String key : keys) {
    nameValuePairs.add(new BasicNameValuePair(key, requestParameter.get(key)));
  }
}
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import axios from 'axios'

const result = await axios.post(
  "https://api.lovense.com/api/basicApi/getToken",
  {
    token: "{Lovense developer token}",
    uid: "{user ID on your application}",
    uname: "{user nickname on your application}"
  }
)
1
2
3
4
5
6
7
8
9
10

Result:

{
  code: 0
  message: "Success"
  data: {
      "authToken": "{autoToken}"
  }
}
1
2
3
4
5
6
7

Step 2: Validate authorization

After generating the authToken in the previous step, submit it to Lovense on the client-side to verify authorization. This will return socket connection information.

WARNING

Please use Socket.IO for client 2.xopen in new window when connecting to the socket service on the client side

API URL: https://api.lovense-api.com/api/basicApi/getSocketUrl

Method: POST

Content Type: application/json

Parameters:

NameDescriptionRequired
platformYour Website Name (shown in the Developer Dashboard)yes
authTokenAuthorization tokenyes

Return:

NameDescriptionType
codereturn code, 0 for successint
messagereason for failure when the request failsstring
dataresult dataobject
data.socketIoPathsocket.io pathstring
data.socketIoUrlsocket.io urlstring

Example:

String url= "https://api.lovense.com/api/basicApi/getSocketUrl";
Map<String, String> requestParameter = new HashMap<String, String>();
//TODO initialize your parameters:
requestParameter.put("platform", "{platform}");
requestParameter.put("authToken", "{authToken}");
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
if (requestParameter != null && !requestParameter.isEmpty()) {
  Set<String> keys = requestParameter.keySet();
  for (String key : keys) {
    nameValuePairs.add(new BasicNameValuePair(key, requestParameter.get(key)));
  }
}
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "utf-8"));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import axios from 'axios'

const result = await axios.post(
  "https://api.lovense.com/api/basicApi/getSocketUrl",
  {
    platform: "{platform}",
    authToken: "{authToken}"
  }
)
1
2
3
4
5
6
7
8
9

Result:

{
  code: 0
  message: "Success"
  data: {
      "socketIoPath": "/xxx",
      "socketIoUrl": "xxx"
  }
}
1
2
3
4
5
6
7
8

Step 3: Get QR code

After connecting the socket, obtain the user's QR code information by sending the basicapi_get_qrcode_ts event, which is used for interface display. The response data is returned with the event basicapi_get_qrcode_tc

Emit Event: basicapi_get_qrcode_ts

Listen Event: basicapi_get_qrcode_tc

Return:

NameDescriptionType
codeReturn code, 0 for successint
messageReason for failure when the request failsstring
dataResult dataobject
data.qrcodeQR code raw data. You can use it to generate a QR codestring
data.qrcodeUrlQR code picture urlstring
data.ackIdIf you pass a ackId when sending an event, a consistent ackId will be returned herestring

Example:

import io from 'socket.io-client'

const socket = io('socketIoUrl', { path: 'socketIoPath', transports: ['websocket'] })
const ackId = '24fsf2536fs7324hj647f5'

socket.emit('basicapi_get_qrcode_ts', {
  ackId: ackId
})

socket.on('basicapi_get_qrcode_tc', res => {
  let resData = res ? JSON.parse(res) : {}
  if (resData.data && resData.data.ackId === ackId) {
    console.log(resData)
  }
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Result:

{
  code: 0
  message: "Success"
  data: {
    "qrcodeUrl": "{qrcodeUrl}",
    "qrcode": "{qrcode}"
    "ackId": "24fsf2536fs7324hj647f5"
  }
}
1
2
3
4
5
6
7
8
9

Step 4: Get device information

The toy and device information can be obtained with the event basicapi_update_device_info_tc

Listen Event: basicapi_update_device_info_tc

Example:

import io from 'socket.io-client'

const socket = io('socketIoUrl', { path: 'socketIoPath', transports: ['websocket'] })

socket.on('basicapi_update_device_info_tc', res => {
  let resData = res ? JSON.parse(res) : {}
  console.log(resData)
})
1
2
3
4
5
6
7
8

Result:

{
  "deviceCode": "xxxxxx",
  "online": true,
  "domain": "192.168.1.xx.lovense.club",
  "httpsPort": 30010,
  "wssPort": 30110,
  "appVersion": "1.3.7",
  "platform": "android",
  "appType": "remote",
  "toyList": [
    {
      "id": "xxxxxxxx",
      "name": "Lush 3",
      "toyType": "lush",
      "nickname": "My Lush",
      "hVersion": "3",
      "fVersion": 300,
      "battery": 100,
      "connected": true
    }
  ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

Step 5: Command the toy(s)

We provide two ways to send toy commands.

By local

If the user's app and your application are on the same LAN, you can use the obtained device information to send toy command. Please refer to the documentation for specific parameters.

By server

You can also send commands remotely with the latest basicapi_send_toy_command_ts event. The parameters are the same as those sent by local application.

import io from 'socket.io-client'

const socket = io('socketIoUrl', { path: 'socketIoPath', transports: ['websocket'] })

socket.emit('basicapi_send_toy_command_ts', {
  command: "Function",
  action: "Vibrate:16",
  timeSec: 20,
  apiVer: 1
})
1
2
3
4
5
6
7
8
9
10

Socket Event List

Listen
NameDescriptionTrigger
basicapi_get_qrcode_tcReturns QR code informationwhen 'basicapi_get_qrcode_ts' event is sent
basicapi_update_device_info_tcReturns device informationdevice information update
basicapi_update_app_status_tcReturns the app connection statususer scans the code to establish a connection
basicapi_update_app_online_tcReturns the app network statusthe connection status of Lovense APP and Lovense server
Emit
NameDescription
basicapi_get_qrcode_tsget QR code information
basicapi_send_toy_command_tssend toy commands by server

Basic JS SDK

Basic JS SDK is a javascript implementation of the Standard Socket API solution above. We suggest to directly integrate this if you are a web application developer.

Here is a sample Demo for your reference.

Import the Javascript file

Import the Javascript file to your web page. This Javascript will declare a global variable LovenseBasicSdk on the page.

<script src="https://api.lovense-api.com/basic-sdk/core.min.js"></script>
1

TIP

Please add the following domains to your CSP whitelist.

*.lovense.com *.lovense-api.com *.lovense.club:*

Initialize

Declare an instance object using the LovenseBasicSdk constructor. The ready event is triggered after successful declaration.

Please refer here to see how to request authToken for your users.

/**
 * @param {object} option
 * @param {string} option.uid user ID on your application
 * @param {string} option.platform this is the Website Name shown in the developer dashboard
 * @param {string} option.authToken authorization token
 * @param {boolean} option.debug optional, whether to print debug messages on the console
 * @returns {object} instance object
 */
LovenseBasicSdk(option)
1
2
3
4
5
6
7
8
9

Example:

const basicSdkInstance = new LovenseBasicSdk({
  platform: '{platform}',
  authToken: '{authToken}',
  uid: '{uid}',
  debug: true
})
basicSdkInstance.on('ready', instance => {
  console.log('ready')
})
1
2
3
4
5
6
7
8
9

Methods

getQrcode

Get the QR code to display on the interface. This is an asynchronous method.

Example:

const basicSdkInstance = new LovenseBasicSdk({
  platform: '{platform}',
  authToken: '{authToken}',
  uid: '{uid}',
  debug: true
})
basicSdkInstance.on('ready', async instance => {
  try {
    const codeRes = await instance.getQrcode()
    console.log(codeRes)
    // return:
    // {
    //   "qrcodeUrl": "https://apps.lovense-api.com/UploadFiles/qr/20220725/9b03dfb900af4328b2eb0573a39ec5e0.jpg",
    //   "qrcode": "{\"type\":5,\"data\":\"2Td5iU0YoWSpsE4fx5WSMUbt+khTj0d/GggSrRTVs8Sz4EOOpoISvcRUO3P6/WFxA/FHwfEgLkuCG4kP2m1X2Q==\"}"
    // }
  } catch (e) {
    console.error(e.message)
  }
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
getAppStatus

Returns the app connection status.

Example:

basicSdkInstance.getAppStatus()
// return: true | false
1
2
getOnlineToys

Get connected toy(s) information.

basicSdkInstance.getOnlineToys()

// return:
[{
  "id": "xxxxxxxx",
  "name": "Lush 3",
  "toyType": "lush",
  "nickname": "My Lush",
  "hVersion": "3",
  "fVersion": 300,
  "battery": 100,
  "connected": true
}]
1
2
3
4
5
6
7
8
9
10
11
12
13
getToys

Get toy(s) information.

Example:

basicSdkInstance.getToys()

// return:
[{
  "id": "xxxxxxxx",
  "name": "Lush 3",
  "toyType": "lush",
  "nickname": "My Lush",
  "hVersion": "3",
  "fVersion": 300,
  "battery": 100,
  "connected": true
}]
1
2
3
4
5
6
7
8
9
10
11
12
13
checkToyOnline

Check if any toys have been connected.

Example:

basicSdkInstance.checkToyOnline()
// return: true | false
1
2
getDeviceInfo

Get device Information.

basicSdkInstance.getDeviceInfo()

// return:
{
  "deviceCode": "xxxxxx",
  "domain": "192.168.1.xx.lovense.club",
  "httpsPort": 30010,
  "appVersion": "1.3.7",
  "platform": "android",
  "appType": "remote"
}
1
2
3
4
5
6
7
8
9
10
11
sendToyCommand

Send commands to toys.

Parameters:

NameTypeDescriptionRequired
vibrateNumberVibration strength, range 0-20no
rotateNumberRotation strength, range 0-20. Supported by Nora.no
pumpNumberPump strength, range 0-3. Supported by Max/Max 2.no
thrustingNumberThrusting strength, range 0-20. Supported by the Lovense Sex Machine and Gravity.no
fingeringNumberFingering strength, range 0-20. Supported by Flexer.no
suctionNumberSuction strength, range 0-20. Supported by Tenera.no
timeNumberTotal running time, 0 = indefinite length. Otherwise, the running time should be greater than 1, default 0no
toyIdStringToy ID. If you don’t include this, it will be applied to all toysno

Example:

// vibrate at 5th strength for all connected toys
basicSdkInstance.sendToyCommand({
  vibrate: 5
})

// vibrate 60 seconds at 5th strength for all connected toys
basicSdkInstance.sendToyCommand({
  vibrate: 5,
  time: 60
})

// vibrate 60 seconds at 5th strength for toys 234s25rsga3ts
// rotate 60 seconds at 10th strength for toys 234s25rsga3ts
basicSdkInstance.sendToyCommand({
  vibrate: 5,
  rotate: 10,
  time: 60,
  toyId: '234s25rsga3ts'
})
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sendPatternCommand

Send pattern command.

Parameters:

NameTypeDescriptionRequired
strengthStringStrength pattern. Use 0-20 to form a string of numbers, separated by a semicolon. Supports up to 50 numbers, for example: 20;20;5;20;10yes
timeNumberTotal running time, 0 = indefinite length. Otherwise, running time should be greater than 1, default 0no
intervalNumberVibration intervals in milliseconds. Should be greater than 100,default 150no
vibrateBooleanWhether to enable vibration, default trueno
rotateBooleanWhether to enable rotation. Supported by Nora.no
pumpBooleanWhether to enable pump. Supported by Max/Max 2.no
thrustingBooleanWhether to enable thrusting. Supported by the Lovense Sex Machine and Gravity.no
fingeringBooleanWhether to enable fingering. Supported by Flexer.no
suctionBooleanWhether to enable suction. Supported by Tenera.no
toyIdStringToy ID. If you don’t include this, it will be applied to all toysno

Example:

basicSdkInstance.sendPatternCommand({
  strength: "6;8;10;12;14;20;20;20;16;14;12;10;8;6;6",
  time: 60
})
1
2
3
4
sendPresetCommand

Send a command from Lovense preset patterns.

NameTypeDescriptionRequired
nameStringPreset pattern name. Supports "pulse", "wave", "fireworks", "earthquake"yes
timeNumberTotal running time, 0 = indefinite length. Otherwise, running time should be greater than 1, default 0no
toyIdStringToy ID. If you don’t include this, it will be applied to all toysno

Example:

basicSdkInstance.sendPresetCommand({
  name: "pulse",
  time: 60
})
1
2
3
4
stopToyAction

Stop toy’s response.

Parameters:

NameTypeDescriptionRequired
toyIdStringToy ID. If you don’t include this, it will be applied to all toysno

Example:

basicSdkInstance.stopToyAction()
1
destroy

Destroy the instance.

Example:

basicSdkInstance.destroy()
1

Event

ready

Listen for the ready event, which will be called after successful initialization. You can use the instance normally after this event is triggered.

Example:

const basicSdkInstance = new LovenseBasicSdk({
  platform: '{platform}',
  authToken: '{authToken}',
  uid: '{uid}',
  debug: true
})
basicSdkInstance.on('ready', instance => {
  console.log('ready')
})
1
2
3
4
5
6
7
8
9
appStatusChange

Triggered when the app connection state changes. For example, users scan the QR code and establish a connection successfully.

Example:

basicSdkInstance.on('appStatusChange', status => {
  // the app connection status
  // status = true | false
})
1
2
3
4
toyInfoChange

Triggered when toy information changes.

Example:

basicSdkInstance.on('toyInfoChange', toyInfo => {
  // toyInfo:
  [{
    "id": "xxxxxxxx",
    "name": "Lush 3",
    "toyType": "lush",
    "nickname": "My Lush",
    "hVersion": "3",
    "fVersion": 300,
    "battery": 100,
    "connected": true
  }]
})
1
2
3
4
5
6
7
8
9
10
11
12
13
toyOnlineChange

Triggered when the toy connection state changes.

Example:

basicSdkInstance.on('toyOnlineChange', status => {
  // have any toys been connected
  // status = true | false
})
1
2
3
4
deviceInfoChange

Triggered when the device information changes.

Example:

basicSdkInstance.on('deviceInfoChange', deviceInfo => {
  // deviceInfo:
  {
    "deviceCode": "xxxxxx",
    "domain": "192.168.1.xx.lovense.club",
    "httpsPort": 30010,
    "appVersion": "1.3.7",
    "platform": "android",
    "appType": "connect"
  }
})
1
2
3
4
5
6
7
8
9
10
11
Last Updated: 4/4/2023, 10:14:18 AM