open bouquet readme

Open Bouquet Developer Hub

Welcome to the open bouquet developer hub. You'll find comprehensive guides and documentation to help you start working with open bouquet readme as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Documentation

Basic tutorial

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

This small js app will authenticate to 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 as an HTML script

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

Including 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 tutorial on how to generate an API Key

In order to simplify this tutorial, we generated an API Key to access our public demo environment which api endpoint is https://demo.openbouquet.io/release/v4.2.
This key is linked to a client api-key-client and provides a 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 for example we'll get the the current logged User by call the /rs/user endpoint

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

example using a Promise

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

example using a Callback

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

Run a query given 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 our guide 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 much more options to build sophisticated queries using date-ranges, filters, rollups... please refer to the API Query reference

Enjoy

Basic tutorial