-
Notifications
You must be signed in to change notification settings - Fork 0
Developers: API Examples 2
Brandon Jank edited this page Nov 22, 2017
·
1 revision
CURL REGISTER EXAMPLE:
curl -X POST https://smartsettia.com/api/register \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{"uuid": "4dbc0776-9b44-11e7-abc4-cec278b6b50a", "challenge": "temppass"}'
PYTHON REQUESTS REGISTER EXAMPLE:
url = "https://smartsettia.com/api/register"
data = {"uuid": "4dbc0776-9b44-11e7-abc4-cec278b6b50a", "challenge": "temppass"}
headers = {'Content-type': 'application/json', 'Accept': 'application/json'}
response = requests.post(url, data=json.dumps(data), headers=headers)
SERVER RESPONSE (Note that if a new record is created, 201 is returned instead of 200 for a registration that exists):
HTTP/1.1 200 OK
date: Mon, 18 Sep 2017 17:10:25 GMT
server: Apache/2.4.7 (Ubuntu)
cache-control: no-cache, private
x-ratelimit-limit: 60
x-ratelimit-remaining: 59
content-length: 154
keep-alive: timeout=5, max=100
content-type: application/json
X-BACKEND: apps-proxy
{"data":{"name":"New Device","uuid":"9dbc0776-9b44-11e7-abc4-cec278b6b50a","id":6,"token":"u0tQGeyuGdikOOFWhfDfwxbR2Z7rTN9Hc5hZN1JHsg4uUfkTi8UUu5nh0XLm"}}
CURL UPDATE EXAMPLE:
curl -X POST https://smartsettia.com/api/update \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer u0tQGeyuGdikOOFWhfDfwxbR2Z7rTN9Hc5hZN1JHsg4uUfkTi8UUu5nh0XLm" \
-d '{"uuid": "9dbc0776-9b44-11e7-abc4-cec278b6b50a", "token": "u0tQGeyuGdikOOFWhfDfwxbR2Z7rTN9Hc5hZN1JHsg4uUfkTi8UUu5nh0XLm", "version": "0.1.1", "hostname": "device.local", "ip": "192.168.1.213", "mac_address": "1122334455667788", "time": "2000-12-31 23:59:59", "cover_status": "closed", "error_msg": "", "limitsw_open": "0", "limitsw_closed": "1", "light_in": "0", "light_out": "100", "cpu_temp": "30", "temperature": "28", "humidity": "34"}'
PYTHON REQUESTS UPDATE EXAMPLE:
url = "https://smartsettia.com/api/update"
data = {"uuid": "4dbc0776-9b44-11e7-abc4-cec278b6b50a", "token": "u0tQGeyuGdikOOFWhfDfwxbR2Z7rTN9Hc5hZN1JHsg4uUfkTi8UUu5nh0XLm", "version": "0.1.1", "hostname": "device.local", "ip": "192.168.1.213", "mac_address": "1122334455667788", "time": "2000-12-31 23:59:59", "cover_status": "closed", "error_msg": "", "limitsw_open": "0", "limitsw_closed": "1", "light_in": "0", "light_out": "100", "cpu_temp": "30", "temperature": "28", "humidity": "34"}
headers = {'Content-type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Bearer u0tQGeyuGdikOOFWhfDfwxbR2Z7rTN9Hc5hZN1JHsg4uUfkTi8UUu5nh0XLm'}
response = requests.post(url, data=json.dumps(data), headers=headers)