open bouquet readme

Open Bouquet Developer Hub

Welcome to the Open Bouquet documentation hub for developers. You'll find comprehensive guides and documentation to help you start working with Bouquet as quickly as possible, as well as providing you with support if you get stuck on anything.

Below you will find links to our Quick Start Guide and to the general User Guide.
If you're new to Open Bouquet, there is an Introduction section at the start of the User Guide.
If you prefer the "Just Do It" approach, then I would suggest the Quick Start Guide ("Getting started with Bouquet") which explains how to get started with Bouquet from installation to working with projects and queries -- including links to more detailed information while you're working on through the quick start guide.

Build your first app

This short tutorial aims at showing the basics of using the bouquet-js library.

This small Javascript app will authenticate towards the Bouquet API using a public "guest" access and run an analysis defined by a Bouquet Bookmark.

Note : this small app is available for preview as a JSFiddle

Include bouquet.js

Bouquet-js is a Universal Javascript Library meaning that it can be used either from a Browser or from NodeJS.

Including it as an HTML script

<script src="//rawgit.com/openbouquet/bouquet-js/master/dist/bouquet.min.js"></script>

Including it as a NPM library

npm install bouquet-js

Authenticate

Using an API key

API Key is a simple way of providing a guest access to your data - see the section on how to generate an API Key

In order to simplify this tutorial, we generated an API Key to access our public demo environment for which the api endpoint is 'https://demo.openbouquet.io/release/v4.2'.
This key is linked to a client 'api-key-client' and provides read access to a limited set of data.

Using this key, you can now create a new Bouquet client instance :

   var bouquet = new Bouquet({
       url : '//demo.openbouquet.io/release/v4.2',
       clientId : 'api-key-client',
       apiKey : 'eyJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJhcGkta2V5LWNsaWVudCIsInN1YiI6IjU4YWM1Y2FiMTVhYmNjMTJiYjUwYTU0MCIsInVzZXJFbWFpbCI6ImRlbW9AbG9jYWxob3N0LmNvbSIsImN1c3RvbWVySWQiOiI1OGFjNTNjMDE1YWJjYzEyYmI1MGE0NWIiLCJqdGkiOiJnTmF3dHdiZzRaYXRtQ1JXVVRQYnFnIiwiZXhwIjo0NjQxNTM0NTE5LCJpYXQiOjE0ODc5MzQ1MTksIm5iZiI6MTQ4NzkzNDM5OX0.g5f1DHxESj9PvC5meP8UKXmcZzbGZIiW-qwZ7mNAZWTlMlaAdIn1EBOZzB9oAwHzQxS0qez0iRDac874YCmnHrwYI8kgVoJQvbbJedKIJjfP_V_ZPvMiAfsX0wqeCmqG4_uXZoAh_sumvyDkKGfzutAfpR3DCVkWTqfYZ-iornkyYwH89Yqe_yBNQPO4pXpf3Dg68BlruZqc-tiow3ytynyxuEYEOPYIuyRL-fLpjNstRGa_gXIQYBx9v1yVGlZsQFVviJ5PMbCgIduM36g5leA_IXprw46KxjH_snbnEvAHypZCwhNaJJxlLGBEWTMnFKqytR68CGURskRM2D0VPQ'
   });

Perform an API request

Here we'll get the the current logged in User by call the '''/rs/user''' endpoint

For all method calls you can get the results either via a Promise or a Callback

An example using a Promise

   bouquet.request("/rs/user")
   .then( function(user) {
       // display user
   }).catch(function(err) {
       // handle error
   });

An example using a Callback

 bouquet.request("/rs/user", function(error, user) {
        // display user or handle any error
   });

Run a query with a Bouquet Bookmark

Now that we're authenticated, we can query the '/analytics' endpoint to get the results of an analysis.

For this tutorial, we defined a Bouquet Bookmark on our Demo project. This Bookmark is referenced by the following ID : '@'5899bc6715abcc6bed69d766'.@bookmark:'58a5dc6b45d778b2bdb231c9''. For more info on Bookmarks please read the section How to explore your data

Here we're going to query get the first 1000 rows of the analysis defined by this Bookmark. The '/analytics' endpoint accepts several ways of passing this query.

Method #1 using a single query string

var bookmarkId = "@'5899bc6715abcc6bed69d766'.@bookmark:'58a5dc6b45d778b2bdb231c9'";

bouquet.request("/analytics/" + bookmarkId + "/query?limit=1000")
.then(function(data) {
    // display data
})
.catch(function(err) {
    // handle error
});

Method #2 using a query object

var bookmarkId = "/analytics/@'5899bc6715abcc6bed69d766'.@bookmark:'58a5dc6b45d778b2bdb231c9'";

var query = {
   path : "/analytics/" + bookmarkId + "/query",
   data : {
       limit: 1000
   }
};
   
bouquet.request(query)
.then(function(data) {
    // display data
})
.catch(function(err) {
    // handle error
});

Next

Bouquet engine provides many more options to build sophisticated queries using date-ranges, filters, rollups, etc please refer to the API Query reference

Build your first app