Event API
This API allows your service to receive events from the device which occurs when the status of the device changes.
Basic Information
Base URL
Server Phase |
URL | Remark |
---|---|---|
QA (DEV) |
https://{region}-qa-ext.lgthinq.com |
region
|
OP |
https://{region}-ext.lgthinq.com |
API List
Method | Summary |
---|---|
POST /event/{device-id} |
Subscribes to events of the device when the device status changes |
DELETE /event/{device-id} |
Unsubscribes to events of the device when the device status changes |
Subscribe to Device Events
POST /event/{device-id}
Description
This method allows your service to receive events form the device.
An event occurs when the status of the device changes. This method is used to notify the device status when the device status is changed. It does not provide device status in real-time.
POST {Base_URL}/event/{device-id}
If the method is successfully called, your service will receive the events of the device specified as device-id
. The event message includes the device-id
, device type (appliance type) and device status data. Refer to Event Messages for details.
Parameter
Header Parameters
Common Header
Body Parameters
Enter the expiration of the event subscription as follows:
Name |
Type |
Required |
Description |
Default |
|
---|---|---|---|---|---|
expire |
object |
optional |
An object which defines the expiration for the event subscription as follows: |
- |
|
|
unit |
string |
optional |
The unit for expiration time of the event subscription.
|
HOUR |
|
timer |
integer |
optional |
The expiration time of the event subscription.
|
1 |
This method works for the amount of time defined in timer
in the unit of time defined in unit
. In other words, after subscribing to the device event, if the time set in the timer
in has been exceeded, your service does not receive the event anymore.
Result
There are two results (Succeeded, Failed) for this method call.
Succeeded
If succeeded, it returns a null value.
Failed
If failed, it returns error codes and error messages defined in the Common Response.
Example of Request
[POST] {{ENDPOINT_URL}}/event/{device-id} ## Header { “Authorization”: "Bearer 3b565aa79ac4abaa37809a8b8b745499bd05bb3ef0ed75fe350ad2c696b4b956bddfa35e76c26a12ab33c643bed579dd", “x-country-code”: "KR", “x-message-id”: "0123456789012345678912", “x-service-id”: "470ae4c534ba143cad86e5c3", “x-service-key”: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZXJ2aWNlSWQiOiI0NzBhZTRjNTM0YmExNDNjYWQ4NmU1YzMiLCJ0b2tlblNlZWQiOiI1Zjc2MWQwMDU2YmE4NWJkIiwidGltZSI6MTUxNjM0MTkzMn0.aznAEnUItCWc2UAFvoiIYDw0SCJDoY5xVCNnUyUJeiI", “content-type”: "application/json" } ## Body { “expire”: { “unit”: “HOUR”, “timer”: 1 } }
Example of Response
{ “messageId”: “c2d362a0-dd0f-11e6-a7c7-abfb76e3e664”, “timestamp”: “1284101485”, “response”: {} }
Unsubscribe to Device Events
DELETE /event/{device-id}GET
Description
This method allows your service to cancel the subscription to the events of the device.
DELETE {Base_URL}/event/{device-id}
If the method is successfully called, your service does NOT receive event messages anymore from the device designated by device-id
when the device status changes. Events of that device cannot be received until a subscription has been requested again using POST /event/{device-id}
.
Parameter
Header Parameters
Common Header
Body Parameters
None
Result
There are two results (Succeeded, Failed) for this method call.
Succeeded
If succeeded, it returns a null value.
Failed
If failed, it returns error codes and error messages defined in the Common Response.
Example of Request
[DELETE] {{ENDPOINT_URL}}/event/{device-id} ## Header { “Authorization”: "Bearer 3b565aa79ac4abaa37809a8b8b745499bd05bb3ef0ed75fe350ad2c696b4b956bddfa35e76c26a12ab33c643bed579dd", “x-country-code”: "KR", “x-message-id”: "0123456789012345678912", “x-service-id”: "470ae4c534ba143cad86e5c3", “x-service-key”: "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzZXJ2aWNlSWQiOiI0NzBhZTRjNTM0YmExNDNjYWQ4NmU1YzMiLCJ0b2tlblNlZWQiOiI1Zjc2MWQwMDU2YmE4NWJkIiwidGltZSI6MTUxNjM0MTkzMn0.aznAEnUItCWc2UAFvoiIYDw0SCJDoY5xVCNnUyUJeiI" }
Example of Response
{ “messageId”: “c2d362a0-dd0f-11e6-a7c7-abfb76e3e664”, “timestamp”: “1284101485”, “response”: {} }
Event Messages
The event occurs when the status of the device is changed. Refer to the following table for the definition of event.
Name |
Type |
Description |
|
---|---|---|---|
event |
object |
The object containing the information on the event. |
|
|
deviceId |
string |
The device ID |
|
deviceType |
enum |
The appliance type |
|
report |
object |
Shows the changed device status. Refer to the Device Profile > Status Inquiry Result for the changed device status as follows: |
pushType |
enum |
DEVICE_STATUS |
|
userList |
List |
List of users who registered the device push |
Example
{ "messageId": "W1FKFRBZRkiuFAfU9pb6kw", "timestamp": "2019-06-20T01:14:27.069000", "event": { "pushType": "DEVICE_STATUS", "serviceId": "6b2011e7ff026e984215522d", "deviceId": "HW1-69C3EDD9-1993-4442-B139-794CA5997ECA", "report": { { device status } }, "deviceType": "DEVICE_WASHER", "userList": ["KR1910213944934"], } }