Lifx

Wi-Fi enabled LED smart lights

Go to site

Integrate the Lifx API with the MongoDB API

Setup the Lifx API trigger to run a workflow which integrates with the MongoDB API. Pipedream's integration platform allows you to integrate Lifx and MongoDB remarkably fast. Free for developers.

Connect Lifx

return await require("@pipedreamhq/platform").axios(this, {
  url: `https://api.lifx.com/v1/lights/all`,
  headers: {
    Authorization: `Bearer ${auths.lifx.oauth_access_token}`,
  },
})

Connect MongoDB

const MongoClient = require('mongodb').MongoClient

const {
  database,
  hostname,
  username,
  password,
} = auths.mongodb

const url = `mongodb+srv://${username}:${password}@${hostname}/test?retryWrites=true&w=majority`
const client = await MongoClient.connect(url, { 
  useNewUrlParser: true, 
  useUnifiedTopology: true 
})

const db = client.db(database)
// Enter your target collection as a parameter to this step
this.res = await db.collection(params.collection).insertOne({ name: "Luke Skywalker" })

await client.close()