Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lifx-http-api

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lifx-http-api - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

package.json
{
"name": "lifx-http-api",
"version": "1.0.0",
"version": "1.0.1",
"description": "Thin wrapper around the Lifx HTTP API",

@@ -30,3 +30,3 @@ "main": "source/lifx.js",

},
"license": "GPL-3.0",
"license": "MIT",
"dependencies": {

@@ -33,0 +33,0 @@ "lodash": "^4.2.1",

# Lifx HTTP Api Node.js Wrapper
![Dependency Status](https://david-dm.org/klarstil/lifx-http-api.svg)
[![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)
A thin Node.js API wrapper of the [Lifx HTTP protocol](http://api.developer.lifx.com/).
This library is not, in any way, affiliated or related to LiFi Labs, Inc.. Use at your own risk.
This library is not, in any way, affiliated or related to Lifi Labs, Inc.. Use at your own risk.

@@ -12,3 +12,3 @@ ## Installation

```sh
$ npm install http-lifx-api --save
$ npm install lifx-http-api --save
```

@@ -80,25 +80,2 @@

#### `client.listScenes([cb])`
Lists all the scenes available in the users account.
Option | Type | Default | Description
------ | ---- | ------- | -----------
`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.
**Usage example:**
```js
// Using callbacks
client.listScene(function(err, data) {
if(err) {
console.error(err);
return;
}
console.log(data)
});
// Using promises
client.listScenes().then(console.log, console.error);
```
### Modifying light state

@@ -292,2 +269,27 @@

### Working with scenes
#### `client.listScenes([cb])`
Lists all the scenes available in the users account.
Option | Type | Default | Description
------ | ---- | ------- | -----------
`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.
**Usage example:**
```js
// Using callbacks
client.listScene(function(err, data) {
if(err) {
console.error(err);
return;
}
console.log(data)
});
// Using promises
client.listScenes().then(console.log, console.error);
```
#### `client.activateScene(selector, [duration], [cb])`

@@ -315,2 +317,4 @@ Activates a scene from the users account.

### Utility methods
#### `client.validateColor(color, [cb])`

@@ -337,2 +341,98 @@ This method lets you validate a user's color string and return the hue, saturation, brightness and kelvin values that the API will interpret as.

### Client API
#### `client.getVersion()`
Returns the api version.
**Usage example:**
```js
client.getVersion(); // outputs "v1"
```
#### `client.setVersion(version)`
Sets the api version. Returns `true` if the version was set sucessfully, otherwise `false`.
Option | Type | Default | Description
------ | ---- | ------- | -----------
`version` | string | | API version which will be used by the `Client` object.
**Usage example:**
```js
client.setVersion('v2beta');
```
#### `client.getUrl()`
Returns the api url.
**Usage example:**
```js
client.getUrl(); // outputs "https://lifx.com/api/"
```
#### `client.setUrl(url)`
Sets the api url. Returns `true` if the url was set sucessfully, otherwise `false`.
Option | Type | Default | Description
------ | ---- | ------- | -----------
`url` | string | | API url which will be used by the `Client` object.
**Usage example:**
```js
client.setUrl('https://my-lifx-api-url.com');
```
#### `client.getApiUrl()`
Returns the full Lifx api endpoint
**Usage example:**
```js
client.getApiUrl(); // outputs "https://lifx.com/api/v1"
```
#### `client.getBearerToken()`
Returns the bearer authentication token.
**Usage example:**
```js
client.getBearerToken(); // outputs "<your-token>"
```
#### `client.setBearerToken(token)`
Sets the bearer authentication token. Returns `true` if the token was set sucessfully, otherwise `false`.
Option | Type | Default | Description
------ | ---- | ------- | -----------
`token` | string | | Bearer authentication token which will be used by the `Client` object.
**Usage example:**
```js
client.setBearerToken('<your-token>');
```
#### `client.send(settings, cb)`
Sends a request to the Lifx API.
Option | Type | Default | Description
------ | ---- | ------- | -----------
`settings` | Object | `{}` | `request` configuration settings. See the [offical documentation](https://github.com/request/request) for further information.
`cb` | function | null | `function(err, data) {}` Callback function which will be called when the HTTP request to the API was processed.
**Usage example:**
```js
client.send({
url: 'lights/all/state',
body: {
power: 'on',
color: 'blue saturation:0.5',
brightness: 0.5,
duration: 5
},
method: 'PUT'
}, function(err, data) {
if (err) console.error(err);
else console.log(data);
})
```
### Client settings

@@ -339,0 +439,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc