Luna Service API Introduction
webOS TV provides the Luna Service that consists of essential services and features for webOS TV. Each service and feature provide application programming interface (API) and its methods for you. With these Luna service APIs, you can request data from the proper service and use the response information to your apps.
Supported Luna Service APIs
webOS TV currently provides the following APIs. More services and APIs are on their way.
API Name | Description |
---|---|
Activity Manager | The Activity Manager is responsible for coordinating work in the system. This includes work currently being done, and work that is scheduled to be done at some point in the future. |
Application Manager | Provides following methods to implicitly launch a resident application based on the requested command and resource types, or to explicitly launch a specified application |
Audio | Provides methods for volume control. |
BLE GATT | Provides methods for BLE GATT. |
Camera | Provides methods that return the information of a camera and microphone. |
Connection Manager | Provides the status of available Internet connections. |
Database | Enables apps to store persistent data. |
Device Unique ID | Provides a method for device identification. |
DRM | Provides methods for managing DRM clients, sending DRM message, and subscribing to DRM rights error information. |
Keymanager3 | Provides methods for for generation and deletion of keys, encryption and decryption, generation and verification of signature, etc. |
Media Database | Enables apps to store large media-related datasets persistently. |
Magic Remote | Provides functions related to the magic remote such as sensor and pairing. |
Settings Service | Provides a method for retrieving system setting value. |
System Service | Provides information about the system time. |
TV Device Information | Provides a method for retrieving TV system information. |
API compatibility on webOS TV device
The following table shows the support for each API on webOS TV platform.
API Name | Supported in webOS TV | ||||||||
---|---|---|---|---|---|---|---|---|---|
1.x | 2.x | 3.x | 4.x | 5.x | 6.x | 22 | 23 | 24 | |
Activity Manager | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Application Manager | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Audio | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
BLE GATT | No | No | No | No | No | No | No | No | Yes |
Camera | Yes | Yes | Yes | Deprecated | Deprecated | Deprecated | Deprecated | Deprecated | Deprecated |
Connection Manager | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Database | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Device Unique ID | No | No | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
DRM | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Keymanager3 | No | No | No | No | No | No | No | No | Yes |
Media Database | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
Magic Remote | Partially | Partially | Partially | Partially | Partially | Partially | Partially | Partially | Yes |
Settings Service | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
System Service | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
TV Device Information | Partially | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |
API compatibility on webOS TV simulator
The following table shows the current support for each API on the simulator.
API Name | Supported in webOS TV Simulator |
---|---|
Activity Manager | Yes |
Application Manager | Yes |
Audio | No |
BLE GATT | No |
Camera | No |
Connection Manager | Yes |
Database | Yes |
Device Unique ID | Yes |
DRM | No |
Keymanager3 | No |
Media Database | Yes |
Magic Remote | Partially (only getSensorData) |
Settings Service | Yes |
System Service | Yes |
TV Device Information | Yes |
API compatibility on webOS TV emulator
The following table shows the current support for each API on the emulator.
API Name | Supported in webOS TV Emulator | |||||
---|---|---|---|---|---|---|
1.2 | 2.x | 3.x | 4.x | 5.x | 6.x | |
Activity Manager | Yes | Yes | Yes | Yes | Yes | Yes |
Application Manager | Yes | Yes | Yes | Yes | Yes | Yes |
Audio | Yes | Yes | Yes | Yes | Yes | Yes |
BLE GATT | No | No | No | No | No | No |
Camera | No | No | No | No | No | No |
Connection Manager | Partially | Partially | Partially | Partially | Partially | Partially |
Database | Yes | Yes | Yes | Yes | Yes | Yes |
Device Unique ID | No | No | No | Yes | Yes | Yes |
DRM | No | No | No | No | No | No |
Keymanager3 | No | No | No | No | No | No |
Media Database | Yes | Yes | Yes | Yes | Yes | Yes |
Magic Remote | No | No | No | No | No | No |
Settings Service | Yes | Yes | Yes | Yes | Yes | Partially |
System Service | Yes | Yes | Yes | Yes | Yes | Yes |
TV Device Information | Partially | Partially | Partially | Partially | Partially | Yes |
Essentials of an API Service Call
Service URI
The Service URI is the URI to the service, in the form:
luna://service name
For example,
luna://com.webos.mediadb
Parameters
Parameters are service request options and are passed as a JSON object. These consist of properties required for the service request as well as a few reserved properties that are common to all service requests.
Method name
The API service method that is called. The method name can be passed as part of the URI or could be passed separately as a property of the parameters object.
Subscribe property
The 'subscribe' property is a reserved property of the parameter object and can be sent to services that allow subscriptions. If the subscribe property is set to true, the method remains in memory and return responses either at periodic intervals or when its data is updated.
Resubscribe property
The 'resubscribe' property is a reserved property of the parameter object and Is used along with the 'subscribe' property. If resubscribe is set to true, it resubscribes to a method after a failure has occurred.
Success callback
The 'onSuccess' property is a reserved property of the parameter object and is used to set a callback function that is called when a request has been successful. This function receives a JSON object containing the service's response data.
Failure callback
The 'onFailure' property is a reserved property of the parameter object and is used to set a function that is called when a request has failed. This function receives a JSON object containing the service's error details.
Complete callback
The 'onComplete' property is a reserved property of the parameter object and is used to set a function that is called when a request is complete (regardless of its success or failure).
Request object
The object returned by a service request call. It can be used to cancel the service request and any associated subscription.
Response object
The JSON object containing the service's response data. It has a reserved property 'returnValue' to indicate the success or failure of a call.
If returnValue is set to false, it means the call failed, and the response object may contain further properties such as the errorCode and errorText that give more information about the error.
If 'returnValue' is true, the call is a success, and the response object may have additional properties depending on the API call being made. If the subscribe property in the parameters was set to true, the response object returns a property subscribed to indicate the success of the subscription. A value of true in subscribed indicates that the subscription was a success.
Calling webOS services from any web application
webOSTV.js is a portable library specialized in webOS TV. Any application can include webOSTV.js, and you can make webOS service calls using the webOS.service.request API.
From webOS TV 4.0, we provide the webOSTV.js library instead of the webOS.js library. Bootplate-web templates contain the webOSTV.js library in its webOSTVjs-x.x.x directory. You can add this library to your app as below:
<script type="text/javascript" src="webOSTVjs-1.1.1/webOSTV.js"></script>
For more details about webOSTV.js, see the webOSTV.js guide. The following code snippet shows how you can call a webOS service using webOSTV.js.
var request = webOS.service.request("luna://com.mycom.helloworld.service", {
method:"hello",
parameters: {"input": inputMessage},
onSuccess: function (args) {
//TO-DO
},
onFailure: function(inError) {
//TO-DO
},
onComplete: function(inResponse) {
//....
},
subscribe: subscribeStatus ,
resubscribe: resubscribeStatus
});
Calling webOS services using Enact
To call webOS services using the Enact framework, see the following documents.
Doc | URL |
---|---|
webOS Support Module | http://enactjs.com/docs/developer-guide/webos/ |
webOS Library |