Client library



The booleans.io client library uses web sockets to push changes to your application in real-time. This is useful for configuring your application or toggling features without redeploying your app.


Our client library is in beta.


JavaScript (client-side)


Download our JavaScript library and add it to your HTML source.

We also have a standalone library. This does not include Socket.io, which you'll need to load yourself. We recommend using the bundled version.


<script type="text/javascript" src="/javascripts/booleans.io.min.js"></script>

Node.js


Install the booleans.io Node.js module.


npm install booleans-io

Import the booleans module in your application code.

import booleans from 'booleans-io';
// or
var booleans = require('booleans-io');

Setup


Create an account and go to the accounts page.

To use Booleans.io in client-side apps, create a client token. These tokens allow read-only access to only your public booleans. You can also use client tokens server-side.

If you need access to private booleans, create an access token. This token will allow read and write access to both public and private booleans, so keep this secure and do not use it in client applications.


Usage


Initialize with your token.

booleans.init(TOKEN, function(data) {
  // booleans have been loaded
});

After initialization completes, you can access booleans you've created on booleans.io by their ID or label.

booleans.get('signedIn').val; // true

Get notified when a boolean changes state.

booleans.get('signedIn').on('update', function(val) {
  console.log(val); // false
});

List all booleans.

booleans.list(); // Array of booleans

API

  

All endpoints require a token in the Authorization header, like this:


curl -X POST http://localhost:3000 -H 'Authorization: Token AUTH_TOKEN'


POST/

val:
optional
Boolean (false)


label:
optional
String ('')


public:
optional
Boolean (false)

Creates and returns a new bool.

curl -X POST http://localhost:3000 -d label=newBoolean -d val=true
PUT/:id

val:
optional
Boolean (false)


label:
optional
String ('')


public:
optional
Boolean (false)

Updates and returns an existing bool.

curl -X PUT http://localhost:3000/[id] -d val=true -d label=newLabel
GET/:id

Gets a bool by ID.

curl http://localhost:3000/[id]
GET/

label:
optional
String

Gets all of your bools. If label query param is passed then returns booleans matching that label.

curl http://localhost:3000?label=myFavoriteBoolean
DELETE/:id

Deletes a bool by ID. Returns 200 status if successful.

curl -X DELETE http://localhost:3000/[id]