DeveloperDeveloper
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
  • Standard Solutions
  • Cam Solutions
  • Native SDKs
  • App Gallery
  • Game Engine Plugins
Forum
Projects Library
Dev Discord
  • Get ctoken for use with Lovense Pattern Editor initialization

Get ctoken for use with Lovense Pattern Editor initialization

API

API URL: https://api.lovense-api.com/api/media/pattern/user/ctoken?userId={userId}&developerToken={developerToken}

Request Protocol: HTTPS Request

Method: GET

Parameters:

ParametersDescriptionTypeRequired
userIdYour user's ID from your platform. userId can be a combination of letters/numbers/hyphen/underscore with length of 6-32 characters.
When the same user opens multiple tabs or refreshes a web page, the userId needs to be kept constant.
stringYes
developerTokenFind this from the Lovense Developer dashboardstringYes

Response Content Type: application/json

Response:

nametypedescription
ctokenstringUsed for video pattern initialization. The ctoken is valid for 24 hours. If it is expired, you will receive an error message.

Request Example:

Sample response:

{
  "result": true,
  "code": 0,
  "message": "success",
  "data": {
    "ctoken": "ug2SHv710OfZCkKH90-E4N-so_Gkv_ihj-m4pvNqp6J6VxGLu5zCwXh1n_FrayAeFDXlOzWw"
  }
}

⚠️ For security reasons, to avoid Developer Token exposure we recommend to perform such requests from server side only, not from the client side.

Example

// <dependency>
//     <groupId>org.apache.httpcomponents</groupId>
//     <artifactId>httpclient</artifactId>
//     <version>4.5.10</version>
// </dependency>

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

public class HttpClientExample {
    public static void main(String[] args) throws IOException {

        CloseableHttpClient httpClient = HttpClients.createDefault();

        try {

            HttpGet request = new HttpGet("https://api.lovense-api.com/api/media/pattern/user/ctoken?userId=[userId]&developerToken=[developerToken]");

            CloseableHttpResponse response = httpClient.execute(request);

            try {
                // 200
                System.out.println(response.getStatusLine().getStatusCode());
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    // return it as String
                    String result = EntityUtils.toString(entity);
                    // json result
                    System.out.println(result);
                }

            } finally {
                response.close();
            }
        } finally {
            httpClient.close();
        }

    }
}

Last Updated:
Explore our Forum or Support to get more inspiration or solve your problems.
Discord Channel
It is an online real-time channel where you can communicate directly with our official administrators or many excellent developers.
Forum
It is a place for Lovense developers to communicate, where you can find solutions to problems or get inspired for your projects.
Support
Find documents and tutorials that may be helpful to you.