Introduction
# Introduction
The custom development APIs included in this documentation are used for controlling the player or retrieving player information. The protocol type used is HTTP. There are 8 types of APIs provided, covering the following functional purposes: general use, network, external device, program, schedule, ColorlightCloud, receiving card, and LAN security.
# Basic Authentication
When LAN encryption is enabled for the player, Basic authentication is required for calling APIs. (See Section VIII for LAN encryption related APIs)
- postman example
- Java code example (use OkHttp framework for Android platform, or add corresponding Basic authentication request header if other method is employed.)
String userName = "admin";
String password = "console";
String auth = "Basic " + android.util.Base64.encodeToString((userName + ":" + password)
.getBytes("utf-8"), Base64.NO_WRAP);
Response response = new OkHttpClient().newCall(new Request.Builder()
.post(requestBody)
.url(url)
.addHeader("Authorization", auth)
.build()).execute();
- bat command (For example, username: admin; password: console)
curl -X PUT http://admin:console@192.168.42.129/api/adb
# Notes
- The String data in the request body should be quoted with double quotation marks (""), which is not required for int data.
- To send request without a player, the request can be sent through the port 8989, 80. To send request from a player (for example, install an APK into the player and make API calls, with the target IP localhost), the request should be sent through the port 8989 (port 80 cannot send request to the server.)
- To use receiving card-related APIs, do not launch the software LEDVISION or LEDUpgrade as failure may occur due to socket preemption.
- Below are some API examples for Android APK development:
Add network request permission in manifest file
<uses-permission android:name="android.permission.INTERNET" />
Add the android:usesCleartextTraffic
attribute to the application
tag in the manifest file (plaintext request is allowed)
android:usesCleartextTraffic="true"
Send request
HandlerThread handlerThread = new HandlerThread("worker");
handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper());
handler.post(this::request);
private void request() {
String TAG = "http request demo";
String url = "http://localhost:8989/api/info.json";
Request request = new Request.Builder()
.get()
.url(url)
.addHeader("Content-Type", "application/json; charset=utf-8")
.build();
Response response;
try {
response = new OkHttpClient.Builder().build().newCall(request).execute();
if (response != null) {
Log.d(TAG, "request: code = " + response.code());
ResponseBody body = response.body();
if (body != null) {
Log.d(TAG, "request: body = \n"
+ body.string());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}