{"id":47802129,"url":"https://github.com/klarstil/lifx-http-api","last_synced_at":"2026-04-03T17:06:37.816Z","repository":{"id":143885948,"uuid":"51101574","full_name":"klarstil/lifx-http-api","owner":"klarstil","description":":bulb: Thin wrapper around the Lifx HTTP API (http://api.developer.lifx.com/)","archived":false,"fork":false,"pushed_at":"2020-07-21T12:34:49.000Z","size":152,"stargazers_count":17,"open_issues_count":4,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T16:28:08.023Z","etag":null,"topics":["bearer-authentication","lifx-api","light","promise"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/klarstil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-04T20:00:08.000Z","updated_at":"2022-08-07T19:12:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"aa85b346-4b81-4d65-af31-317bdfbd03d3","html_url":"https://github.com/klarstil/lifx-http-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/klarstil/lifx-http-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarstil%2Flifx-http-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarstil%2Flifx-http-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarstil%2Flifx-http-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarstil%2Flifx-http-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klarstil","download_url":"https://codeload.github.com/klarstil/lifx-http-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klarstil%2Flifx-http-api/sbom","scorecard":{"id":563109,"data":{"date":"2025-08-11","repo":{"name":"github.com/klarstil/lifx-http-api","commit":"d9299fcf3370c4052b2318e5a2e5637e733d4ed1"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":1,"reason":"Found 3/25 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 7 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T14:13:23.744Z","repository_id":143885948,"created_at":"2025-08-20T14:13:23.744Z","updated_at":"2025-08-20T14:13:23.744Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31364717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T15:19:21.178Z","status":"ssl_error","status_checked_at":"2026-04-03T15:19:20.670Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bearer-authentication","lifx-api","light","promise"],"created_at":"2026-04-03T17:06:37.253Z","updated_at":"2026-04-03T17:06:37.805Z","avatar_url":"https://github.com/klarstil.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lifx HTTP Api Node.js Wrapper\n\n[![NPM Version](https://img.shields.io/npm/v/lifx-http-api.svg)](https://www.npmjs.com/package/lifx-http-api) ![Dependency Status](https://david-dm.org/klarstil/lifx-http-api.svg) [![Build Status](https://travis-ci.org/klarstil/lifx-http-api.svg?branch=master)](https://travis-ci.org/klarstil/lifx-http-api) [![License MIT](https://img.shields.io/badge/license-mit-brightgreen.svg)](https://github.com/klarstil/lifx-http-api/blob/master/LICENSE) [![codecov.io](https://codecov.io/github/klarstil/lifx-http-api/coverage.svg?branch=master)](https://codecov.io/github/klarstil/lifx-http-api?branch=master)\n\nA thin Node.js API wrapper of the [Lifx HTTP protocol](http://api.developer.lifx.com/).\n\nThis library is not, in any way, affiliated or related to Lifi Labs, Inc.. Use at your own risk.\n\n## Installation\n\n```sh\n$ npm install lifx-http-api --save\n```\n\n## Compatibility\n\nNode.js 4.2.6+ is tested and supported on Mac, Linux and Windows.\n\n## Bearer Token\n\nA bearer token is mandatory to use the API. A new token can be obtain in the [Lifx Cloud Settings](https://cloud.lifx.com/).\n\n## Usage\n\nThe thin API wrapper uses a client for network communication. This client handles all requests against the Lifx API.\n\n```js\nvar lifx = require('lifx-http-api'),\n    client;\n    \nclient = new lifx({\n    bearerToken: '\u003cyour api token\u003e'\n});\n```\n\nThe `Client` object provides promises by the great [Q library](https://github.com/kriskowal/q). You can either use callbacks or promises.\n\n```js\n// Using callbacks\nclient.listLights('all', function(err, data) {\n    if(err) {\n    \tconsole.error(err);\n    \treturn;\n    }\n    \n    console.log(data)\n});\n\n// Using promises\nclient.listLights('all').then(console.log, console.error);\n```\n\n### Getting lights and scenes\n\n#### `client.listLights(selector, [cb])`\nGets lights belonging to the authenticated account. Filter the lights using selectors.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`selector` | string | | Selector for the light bulb you want to get. See the [Selector section](http://api.developer.lifx.com/docs/selectors) to get more information.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.listLights('all', function(err, data) {\n    if(err) {\n    \tconsole.error(err);\n    \treturn;\n    }\n    \n    console.log(data)\n});\n\n// Using promises\nclient.listLights('all').then(console.log, console.error);\n```\n\n### Modifying light state\n\n#### `client.setState(selector, settings, [cb])`\nSets the state of the lights within the selector.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`selector` | string | | Selector for the light bulb you want to get. See the [Selector section](http://api.developer.lifx.com/docs/selectors) to get more information.\n`settings` | object | `{}` | State configuration object. See the [official documentation ](http://api.developer.lifx.com/docs/set-state) for further information.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.setState('all', {\n\tpower: 'on',\n\tcolor: 'blue saturation:0.5',\n\tbrightness: 0.5,\n\tduration: 5\t\t\n}, function(err, data) {\n    if(err) {\n    \tconsole.error(err);\n    \treturn;\n    }\n    \n    console.log(data)\n});\n\n// Using promises\nclient.setState('all', {\n\tpower: 'on',\n\tcolor: 'blue saturation:0.5',\n\tbrightness: 0.5,\n\tduration: 5\t\t\n}).then(console.log, console.error);\n```\n\n#### `client.setStates(settings, [cb])`\nThis endpoint allows you to set different states on multiple selectors in a single request.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`settings` | Mixed | `{}` | Multiple State configuration object. See the [official documentation ](http://api.developer.lifx.com/docs/set-state) for further information.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.setState('all', {\n    \"states\": [ {\n        \"selector\": \"all\",\n        \"power\": \"on\"\n    }, {\n        \"selector\": \"group:test\",\n        \"brightness\": 0.5\n    } ],\n    \"defaults\": {\n        \"duration\": 5.0\n    }\n}, function (err, data) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n\n    console.log(data)\n});\n```\n\n#### `client.togglePower(selector, [duration], [cb])`\nTurn off lights if they are on, or turn them on if they are off. Physically powered off lights are ignored.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`selector` | string | `all`| Selector for the light bulb you want to get. See the [Selector section](http://api.developer.lifx.com/docs/selectors) to get more information.\n`duration` | int | 0 | Turning on or off will be faded over the time (in seconds).\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.togglePower('all', 1.5, function (err, data) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n\n    console.log(data)\n});\n```\n\n#### `client.breathe(selector, [settings], [cb])`\nPerforms a breathe effect by slowly fading between the given colors. Use the parameters to tweak the effect.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`selector` | string | `all`| Selector for the light bulb you want to get. See the [Selector section](http://api.developer.lifx.com/docs/selectors) to get more information.\n`settings` | Object | `{}` | Breathe effect object, see the [official documentation](http://api.developer.lifx.com/docs/breathe-effect) for all available parameter.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.breathe('all', {\n    color: '#006633',\n    from_color: '#00AF33',\n    period: 1,\n    cycles: 10,\n    persist: true,\n    power_on: true,\n    peak: 0.8\n}, function (err, data) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n\n    console.log(data)\n});\n```\n\n#### `client.pulse(selector, [settings], [cb])`\nPerforms a pulse effect by quickly flashing between the given colors. Use the parameters to tweak the effect.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`selector` | string | `all`| Selector for the light bulb you want to get. See the [Selector section](http://api.developer.lifx.com/docs/selectors) to get more information.\n`settings` | Object | `{}` | Pulse effect object, see the [official documentation](http://api.developer.lifx.com/docs/pulse-effect) for all available parameter.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.pulse('all', {\n    color: '#006633',\n    from_color: '#00AF33',\n    period: 1,\n    cycles: 10,\n    persist: true,\n    power_on: true,\n    peak: 0.8\n}, function (err, data) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n\n    console.log(data)\n});\n```\n\n#### `client.cycle(selector, [settings], [cb])`\nMake the light(s) cycle to the next or previous state in a list of states.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`selector` | string | `all`| Selector for the light bulb you want to get. See the [Selector section](http://api.developer.lifx.com/docs/selectors) to get more information.\n`settings` | Object | `{}` | Cycle states object, see the [official documentation](http://api.developer.lifx.com/docs/cycle) for all available parameter.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.cycle('all', {\n    \"states\": [{\n        \"brightness\": 1.0\n    }, {\n        \"brightness\": 0.5\n    }, {\n        \"brightness\": 0.1\n    }, {\n        \"power\": \"off\"\n    }],\n    \"defaults\": {\n        \"power\": \"on\", // all states default to on\n        \"saturation\": 0, // every state is white\n        \"duration\": 2.0 // all transitions will be applied over 2 seconds\n    }\n}, function (err, data) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n\n    console.log(data)\n});\n```\n\n### Working with scenes\n\n#### `client.listScenes([cb])`\nLists all the scenes available in the users account.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.listScene(function(err, data) {\n    if(err) {\n    \tconsole.error(err);\n    \treturn;\n    }\n    \n    console.log(data)\n});\n\n// Using promises\nclient.listScenes().then(console.log, console.error);\n```\n\n#### `client.activateScene(selector, [duration], [cb])`\nActivates a scene from the users account.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`selector` | string | `all`| Scene selector. See the [Selector section](http://api.developer.lifx.com/docs/selectors) to get more information.\n`duration` | int | 0 | Fades to the scene (in seconds).\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.activateScene('scene_id:d073d501cf2c', 1.2, function (err, data) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n\n    console.log(data)\n});\n```\n\n### Utility methods\n\n#### `client.validateColor(color, [cb])`\nThis method lets you validate a user's color string and return the hue, saturation, brightness and kelvin values that the API will interpret as.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`color` | string | | Color string you'd like to validate. See the [Color section](http://api.developer.lifx.com/docs/colors) to get more information.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\n// Using callbacks\nclient.validateColor('#0198E1', function (err, data) {\n    if (err) {\n        console.error(err);\n        return;\n    }\n\n    console.log(data)\n});\n```\n\n### Client API\n\n#### `client.getVersion()`\nReturns the api version.\n\n**Usage example:**\n```js\nclient.getVersion();  // outputs \"v1\"\n```\n\n#### `client.setVersion(version)`\nSets the api version. Returns `true` if the version was set sucessfully, otherwise `false`.\n \nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`version` | string | | API version which will be used by the `Client` object.\n\n**Usage example:**\n```js\nclient.setVersion('v2beta');\n```\n\n#### `client.getUrl()`\nReturns the api url.\n\n**Usage example:**\n```js\nclient.getUrl();  // outputs \"https://lifx.com/api/\"\n```\n\n#### `client.setUrl(url)`\nSets the api url. Returns `true` if the url was set sucessfully, otherwise `false`.\n \nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`url` | string | | API url which will be used by the `Client` object.\n\n**Usage example:**\n```js\nclient.setUrl('https://my-lifx-api-url.com');\n```\n\n#### `client.getApiUrl()`\nReturns the full Lifx api endpoint\n\n\n**Usage example:**\n```js\nclient.getApiUrl(); // outputs \"https://lifx.com/api/v1\"\n```\n\n#### `client.getBearerToken()`\nReturns the bearer authentication token.\n\n**Usage example:**\n```js\nclient.getBearerToken();  // outputs \"\u003cyour-token\u003e\"\n```\n\n#### `client.setBearerToken(token)`\nSets the bearer authentication token. Returns `true` if the token was set sucessfully, otherwise `false`.\n \nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`token` | string | | Bearer authentication token which will be used by the `Client` object.\n\n**Usage example:**\n```js\nclient.setBearerToken('\u003cyour-token\u003e');\n```\n\n#### `client.send(settings, cb)`\nSends a request to the Lifx API.\n\nOption | Type | Default | Description\n------ | ---- | ------- | -----------\n`settings` | Object | `{}` | `request` configuration settings. See the [offical documentation](https://github.com/request/request) for further information.\n`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.\n\n**Usage example:**\n```js\nclient.send({\n    url: 'lights/all/state',\n    body: {\n        power: 'on',\n        color: 'blue saturation:0.5',\n        brightness: 0.5,\n        duration: 5        \n    },\n    method: 'PUT'\n}, function(err, data) {\n    if (err) console.error(err);\n    else console.log(data);\n})\n```\n\n### Client settings\n\nThe `Client` object can be configured at initialization:\n\n```js\nvar lifx = require('lifx-http-api'),\n    client;\n    \nclient = new lifx({\n    bearerToken: '\u003cyour api token\u003e',\t// Authentication token\n    version: 'v2beta',\t\t\t\t\t// API version\n    url: 'https://api.lifx.com'\t\t\t// API endpoint\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklarstil%2Flifx-http-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklarstil%2Flifx-http-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklarstil%2Flifx-http-api/lists"}