Proving that you have access to the right account
All requests require an OAuth 2 access token. You can generate an access token in your account settings. Take care to keep access tokens private as they grant remote access to your lights.
Authenticate with HTTP Basic Authentication or the HTTP Authorization header. When using HTTP Basic Authentication the access token is the username and the password may be left blank. Bad access tokens will be rejected by responding with a 401 Forbidden
status code.
HTTPS Requests Only
All requests must be made over HTTPS. Requests made to the HTTP endpoint will be rejected with a
426 Upgrade Required
status code indicating that the connection must be remade using HTTPS to continue.
HTTP Authorization Header
curl -H "Authorization: Bearer {token}" "https://api.lifx.com/v1/lights/all"
<?php
$link = "https://api.lifx.com/v1/lights/all";
$authToken = "{token}";
$ch = curl_init($link);
$headers = array('Authorization: Bearer ' . $authToken);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
?>
import requests
token = "{token}"
headers = {
"Authorization": "Bearer %s" % token,
}
response = requests.get('https://api.lifx.com/v1/lights/all', headers=headers)
HTTP Basic Authentication
curl -u "{token}:" "https://api.lifx.com/v1/lights/all"
<?php
$link = "https://api.lifx.com/v1/lights/all";
$authToken = "{token}";
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_USERPWD, $authToken . ":");
$response = curl_exec($ch);
?>
import requests
token = "{token}"
response = requests.get('https://api.lifx.com/v1/lights/all', auth=(token, ''))