First you need to create an api key in your Braincube dashboard.

Make sure that the api key has the scopes SSO_READ and BRAINCUBE enabled.
The key should be passed to the client's configuration in order to identify yourself.
The following code guides you on how to access data for a set of variables stored on braincube:
<b>from</b> braincube_connector <b>import</b> braincube, client
bc_config = {
"api_key": "abcd", # Use your own api key
"domain": "mybraincube.com",
}
cli = client.get_instance(config_dict=bc_config)
parameters.set_parameter({"parse_date": <b>True</b>})
bc = braincube.get_braincube("demo")
mb = bc.get_memory_base(20)
var_list = ["2000001", "2000013", "2000015", "2000008", "2000022"]
data = mb.get_data(var_list, dataframe=<b>True</b>, label_type="name")
data will contains something like this:
| DATE | NOx | CO | FLOW NATURAL GAS | TEMP AIR | |
|---|---|---|---|---|---|
| 0 | 2016-02-03 00:30:00 | 126.1 | 20.50 | 1700.0 | 26.9 |
| 1 | 2016-02-03 00:40:00 | 126.2 | 27.10 | 1700.0 | 26.8 |
| 2 | 2016-02-03 00:50:00 | 128.2 | 16.00 | 1696.0 | 26.7 |
| 3 | 2016-02-03 01:00:00 | 128.3 | 8.49 | 1700.0 | 26.5 |
| 4 | 2016-02-03 01:10:00 | 106.1 | 0.51 | 1695.0 | 26.4 |
-
cli = client.get_instance(config_dict=bc_config): Create a client with the credentials defined inbc_config. -
parameters.set_parameter({"parse_date": True}): For performance reason, the braincube_connector does not parse the dates to a datetime object by default, it uses strings instead. Turning this setting toTruewill parse the dates in the future. -
bc = braincube.get_braincube("demo"): Access your braincube of choice. -
mb = bc.get_memory_base(20): Select a memory base. -
mb.get_data(var_list, dataframe=True, label_type="name"): Get data for a set of variables referenced to by their bcIds.
Note the two settings:-
dataframe=True: The data are formatted into a Pandas dataframe. -
label_type="name": The braincube_connector uses bcId as a default label for the columns of a dataframe because they are less prone to typos. When readability is the main concern"name"can be chosen for labels.
-