Skip to content

Switch information

Add switch

Description:

Used to add a new switch interface

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/add/switch

Request body:

Note: After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

The request body should be sent as form-data and it should contain the device information as illustrated in the section below:

Field name Description Type
switch_name Name of the switch str
switch_type The type of switch str
switch_token [Optional] Token that will be used to update the switch. If not specified, a random token will be generated str
switch_state [Optional] Initial state for the switch. int
switch_details switch details which will be stored as a json object json
update_period How often the switch will be updated. This time is used to calculate the switch status. If no updates are received withing this period, the device status will be regarded as offline. An email will be sent to the user if notifications are enabled when the status changes. str

JSON format

{
    "switch_name":"Test switch",
    "switch_type":"NC",
    "switch_token":"f5d6dsewwds",
    "switch_state": true,
    "switch_details":"{}",
    "update_period":120
}

Request example:

None

Response

{
    "success": {
        "switch_id": 191683571546635,
        "switch_token": "df45g56df6"
    }
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Switches count

Description:

Used to get number of switches available

Request

Request method:

GET

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/count

Request body:

None

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

None

Response

{
    "success": {
        "switches": 3
    }
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

List switches

Description:

Used to list all the switches for the user

Request

Request method:

GET

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/list

Request body:

Note: After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

None

Request example:

None

Response

{
    "success": [
        {
            "switch_id": 191683571546635,
            "switch_name": "Mine",
            "switch_type": "Switch",
            "update_time": 1683578746,
            "switch_status": "Offline",
            "switch_state": false,
            "switch_token": "df45g56df6",
            "update_period": 60,
            "last_modified": 1683578746,
            "notification_enabled": true,
            "alarms": [
                {
                    "alarm_id": 1683571756707,
                    "device_id": 191683571546635,
                    "alarm_name": "Number 2",
                    "alarm_enabled": true,
                    "alarm_threshold_value": 10.0,
                    "alarm_condition": ">=",
                    "alarm_trigger_time": null,
                    "alarm_repeat_delay": 300,
                    "alarm_akn": null,
                    "update_time": 1683571756,
                    "alarm_triggered": false
                }
            ],
            "switch_details": "{}",
            "whatsapp_enabled": null,
            "sms_enabled": null,
            "requested_state": null,
            "requested_state_time": null
        }
    ]
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Field name Description Type
switch_name Name of the switch str
switch_type The type of switch str
switch_token Token that will be used to update the switch. If not specified, a random token will be generated str
switch_state Initial value for the switch. int
switch_details switch details which will be stored as a json object json
requested_state Used to indicate the last requested state for the switch json
requested_state_time Used to indicate the last requested state time for the switch json
last_modified Indicates the latest update time in epoch json
notification_enabled Indicates if the notifications have been enabled for the interface json
whatsapp_enabled Indicates if whatsapp notifications have been enabled for the interface json
sms_enabled Indicates if sms notifications have been enabled for the interface json
update_period How often the switch will be updated. This time is used to calculate the switch status. If no updates are received withing this period, the device status will be regarded as offline. An email will be sent to the user if notifications are enabled when the status changes. str

Switches Status

Description:

Used to get switch status

Request

Request method:

GET

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/status

Request body:

The request info should be sent as params or json body and it should contain the device information as illustrated in the section below.

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/status?switch_id=65698658484984584&switch_token=fds654gf654gdf56gdf654gdf

Json body example

{
    "switch_id": 65698658484984584,
    "switch_token": "fds654gf654gdf56gdf654gdf"
}

Response

{
    "success": [
        {
            "switch_id": 211674590684890,
            "switch_name": "Door switch",
            "switch_type": "Temperature",
            "update_time": 1674590684,
            "switch_status": "Offline",
            "switch_state": true,
            "switch_token": "68eff1a9010cd7ffac801511f55fcb71a100ca4e",
            "update_period": 900,
            "last_modified": 1674590684,
            "notification_enabled": true,
            "alarms": [
                {
                    "alarm_id": 1675276699283,
                    "device_id": 211674590684890,
                    "alarm_name": "Test",
                    "alarm_enabled": true,
                    "alarm_threshold_value": 30.0,
                    "alarm_condition": ">",
                    "alarm_trigger_time": null,
                    "alarm_repeat_delay": 300,
                    "alarm_akn": null,
                    "update_time": 1675276699,
                    "alarm_triggered": false
                }
            ],
            "whatsapp_enabled": null,
            "sms_enabled": null,
        }
    ]
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Field name Description Type
switch_name Name of the switch str
switch_type The type of switch str
switch_token [Optional] Token that will be used to update the switch. If not specified, a random token will be generated str
switch_state [Optional] Initial value for the the switch. int
switch_details switch details which will be stored as a json object json
last_modified Indicates the latest update time in epoch json
notification_enabled Indicates if the notifications have been enabled for the interface json
whatsapp_enabled Indicates if whatsapp notifications have been enabled for the interface json
sms_enabled Indicates if sms notifications have been enabled for the interface json
update_period How often the switch will be updated. This time is used to calculate the switch status. If no updates are received withing this period, the device status will be regarded as offline. An email will be sent to the user if notifications are enabled when the status changes. str

Switches update

Description:

Used to update switch status

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/update/switch

Request body:

The request info should be sent as params or json body and it should contain the device information as illustrated in the section below.

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/update/switch?switch_id=191679387165463&switch_token=201679387120404&switch_state=False

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
    "switch_state": "true"
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Switches history

Description:

Used to get switch history data

Request

Request method:

GET

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/history

Request body:

The request info should be sent as params or json body and it should contain the device information as illustrated in the section below.

Field name Description Type
min_epoch_tm_sec Minimum time for history record str
max_epoch_tm_sec [Optional] Maximum time for history data. This is set to current epoch time if not specified str
switch_id [Optional] switch ID. All switch history will be returned if not specified str

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/history?min_epoch_tm_sec=1641502593

Json body example

{
    "min_epoch_tm_sec": 1641502593,
    "max_epoch_tm_sec": 1999999999,
    "switch_id": 65897465466
}

Response

{
    "success": [
        {
            "switch_id": 161665308280712,
            "switch_name": "Test",
            "switch_type": "Normally closed",
            "min_time": 1678471370,
            "max_time": 1678471370,
            "data": [
                {
                    "switch_state": true,
                    "update_time": "2023-03-10T20:02:50"
                }
            ]
        }
    ]
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Field name Description Type
switch_id switch ID str
switch_name Name of the switch str
switch_type The type of switch str
min_time Minimum history time available str
max_time Maximum history time int
data Array containing switch data. json

Switches edit

Description:

Used to edit switch information

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/edit/switch

Request body:

The request info should be sent as params or json body and it should contain the device information as illustrated in the section below.

Field name Description Type
switch_name Name of the switch str
switch_type The type of switch str
switch_token [Optional] Token that will be used to update the switch. If not specified, a random token will be generated str
update_period How often the switch will be updated. This time is used to calculate the switch status. If no updates are received withing this period, the device status will be regarded as offline. An email will be sent to the user if notifications are enabled when the status changes. str

Note:

Only the switch owner can edit the interface information.

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/edit/switch?switch_id=545467565849421245489&switch_token=5fgd94dgfd6fsd8d986gd6dg&switch_name=switch&update_period=300

Json body example

{
    "switch_id": "545467565849421245489",
    "switch_token": "5fgd94dgfd6fsd8d986gd6dg",
    "switch_name": "switch",
    "update_period": 300
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Delete switch

Description:

Used to delete switch

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/delete/switch

Request body:

The request info should be sent as params or json body and it should contain the device information as illustrated in the section below.

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/delete/switch?switch_state=true&switch_token=df45ddddsdaewg56df6&switch_id=301659085216623

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Enable alerts

Description:

Used to enable interface alerts

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/enable/alerts

Request body:

None

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/enable/alerts?switch_token=df45ddddsdaewg56df6&switch_id=301659085216623

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Disable alerts

Description:

Used to disable interface alerts

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/disable/alerts

Request body:

None

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/disable/alerts?switch_token=df45ddddsdaewg56df6&switch_id=301659085216623

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Enable whatsapp

Description:

Used to enable interface whatsapp alerts

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/enable/whatsapp

Request body:

None

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/enable/alerts?switch_token=df45ddddsdaewg56df6&switch_id=301659085216623

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Disable whatsapp alerts

Description:

Used to disable interface whatsapp alerts

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/disable/whatsapp

Request body:

None

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/enable/alerts?switch_token=df45ddddsdaewg56df6&switch_id=301659085216623

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Enable sms alerts

Description:

Used to enable interface sms alerts

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/enable/sms

Request body:

None

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/enable/alerts?switch_token=df45ddddsdaewg56df6&switch_id=301659085216623

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
}

Disable sms alerts

Description:

Used to disable interface sms alerts

Request

Request method:

POST

Headers:

Content-type: application/json

URL

https://spoilerinterface.com/interface/switch/disable/sms

Request body:

None

Note:

After authenticating, a cookie will be set on the response and this can be used to make further request without including the api_key in the request params.

Request example:

Params example

https://spoilerinterface.com/interface/switch/enable/alerts?switch_token=df45ddddsdaewg56df6&switch_id=301659085216623

Json body example

{
    "switch_id":301659085216623,
    "switch_token": "df45ddddsdaewg56df6",
}

Response

{
    "success": "success"
}

Field description

The response information contains a success key which indicates that the switch interface has been added successfully