NAV
shell

Introduction

Welcome to the BI Book API!

Authentication

BI Book uses API keys to allow access to the API.

BI Book expects for the API key to be included in all API requests to the server in a header that looks like the following:

X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Alternative authentication methods:

  1. HTTP Basic Authentication

  2. Param token https://bibook.com/bibook/api/v1/endpoint_path?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Response structure

{
  "table_name":"Name_Of_Table", // name of requested table
  "count":1, // returned records
  "page":1, // current page, 1 by default, optional if bulk
  "total_pages":1, // total page number in database, optional if bulk
  "data":[ //array of entities
    {
      "comapany_name": "************", // string value
      "start_date": "2000-01-01", //date value
      "company_id": 11111111 // numeric value
    }
  ]
}

Page size is 10 000 items.

Endpoints

Regenerate credential tokens

Returns json with new regenerated company credential tokens

curl "https://bibook.com/bibook/api/v1/1/credentials/regenerate?refresh_token=CREDENTIAL_REFRESH_TOKEN"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

The above command returns JSON structured like this:

{
  "access_role": "admin",
  "token": "REGENERATED_COMPANY_ADMIN_TOKEN",
  "username": "COMPANY_ID",
  "refresh_token": "REGENERATED_COMPANY_ADMIN_REFRESH_TOKEN"
}

HTTP Request

https://bibook.com/bibook/api/v1/{company_id}/credentials/regenerate?refresh_token=CREDENTIAL_REFRESH_TOKEN

Query Parameters

Parameter Default Description
company_id Required. Company ID
refresh_token Required. Credential refresh token

Files

Returns json with list of company files

curl "https://bibook.com/bibook_files/api/v1/1/files"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

The above command returns JSON structured like this:

[
  {
    "id": 656,
    "filename": "Test.filename",
    "description": "test description",
    "folder": "Test folder",
    "identifier": null
  },
  {
    "id": 658,
    "filename": "Test.filename",
    "description": "test description",
    "folder": "Test folder",
    "identifier": "test.identifier"
  }
]

HTTP Request

GET https://bibook.com/bibook_files/api/v1/{company_id}/files?file_types=csv,xls

Query Parameters

Parameter Default Description
company_id Required. Company ID
folder_id Optional. Folder ID
file_types Optional. File types. For example -'file_types=csv,json,xls,xlsx' or 'file_type=xls'. Here you can set any file extensions separated by comma, or just one.

File

Returns content of file

curl "https://bibook.com/bibook_files/api/v1/1/file/21"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Returns raw file content

Some text from text file

HTTP Request

GET https://bibook.com/bibook_files/api/v1/{company_id}/file/{file_id}

Query Parameters

Parameter Default Description
company_id Required. Company ID
file_id Required. File ID or identifier

Folders

Returns list of folders for company

curl "https://bibook.com/bibook_files/api/v1/1/folders"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

The above command returns JSON structured like this:

[
  {
    "id": 970,
    "name": "Folder1",
    "locked": true,
    "replace_allowed": false,
    "validate_all_files": false,
    "created_at": "2021-04-14"
  },
  {
    "id": 971,
    "name": "Folder2",
    "locked": false,
    "replace_allowed": true,
    "validate_all_files": false,
    "created_at": "2021-04-14"
  }
]

HTTP Request

GET https://bibook.com/bibook_files/api/v1/{company_id}/folders

Query Parameters

Parameter Default Description
company_id Required. Company ID

Tables List

Returns data structure for Database

curl "https://bibook.com/bibook/api/v1/1/tables"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

HTTP Request

GET https://bibook.com/bibook/api/v1/{company_id}/tables

Query Parameters

Parameter Default Description
company_id Required. Company ID

Returns Greenstep database structure as Json

{
  "company_id": "1",
  "tables": [
    {
      "TABLE_SCHEMA": "testing_amoniac_api",
      "TABLE_NAME": "Tablea"
    },
    {
      "TABLE_SCHEMA": "testing_amoniac_api",
      "TABLE_NAME": "Tableb"
    },
    {
      "TABLE_SCHEMA": "testing_amoniac_api",
      "TABLE_NAME": "TEST_VIEW"
    },
    {
      "TABLE_SCHEMA": "testing_amoniac_api",
      "TABLE_NAME": "TEST_VIEW_OTHER_SCHEMA"
    }
  ]
}

Table Data

Returns data from selected table

curl "https://bibook.com/bibook/api/v1/1/table/TableTest?page=1"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Returns one page table data as Json

{
  "table_name": "TableTest",
  "count": 2,
  "page": 1,
  "total_pages": 1,
  "data": [
    {
      "column_a": 1,
      "colc": "10.0"
    },
    {
      "column_a": 152,
      "colc": "265.1"
    }
  ]
}
curl "https://bibook.com/bibook/api/v1/1/table/TableTest?bulk=true"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Returns all table data as Json

[
  {
    "column_a": 1,
    "colc": "10.0"
  },
  {
    "column_a": 152,
    "colc": "265.1"
  }
]
curl "https://bibook.com/bibook/api/v1/1/table/TableTest?skip_underscore=true"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

Returns all table data as Json with keys as they are exits in database.

[
  {
    "Columna": 1,
    "ColC": "10.0"
  },
  {
    "Columna": 152,
    "ColC": "265.1"
  }
]

HTTP Request

GET https://bibook.com/bibook/api/v1/{company_id}/table/{table_name}?page=1&?bulk=false

Query Parameters

Parameter Default Description
company_id Required. Company ID
table_name Required. Name of Greenstep table
page 1 Optional. Number of page
bulk false Optional. Load all data by one request, overrides "page" param
skip_underscore false Optional. Disable column names conversion to JSON standarts and leave as in database

OData Tables Service

OData v4.0 service for working with data from Database. For working with service you need only one url.

curl "https://bibook.com/odata/api/v2/1/Tables.svc"
  -H "X-Bibook-Api-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  -H "Accept: application/xml"

Getting OData service metadata in XML format

<?xml version="1.0" encoding="UTF-8"?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
    <edmx:DataServices>
        <Schema Namespace="BiBook.OData.Model" xmlns="http://docs.oasis-open.org/odata/ns/edm">
            <EntityContainer Name="DefaultContainer">
                <EntitySet Name="TestEntries" EntityType="BiBook.OData.Model.TestEntry"></EntitySet>
            </EntityContainer>
            <EntityType Name="TestEntry" OpenType="true">
                <Property Name="id" Type="Edm.Int64" Nullable="true"></Property>
                <Property Name="cola" Type="Edm.String" Nullable="true"></Property>
                <Property Name="colb" Type="Edm.Date" Nullable="true"></Property>
            </EntityType>
        </Schema>
    </edmx:DataServices>
</edmx:Edmx>

HTTP Request

GET https://bibook.com/odata/api/v2/{company_id}/Tables.svc

Query Parameters

Parameter Default Description
company_id Required. Company ID

Errors

The BI Book API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- Your Gereenstep credentials are invalid. Please contact Greenstep Oy to fix it.
429 Too Many Requests -- You're requesting too many kittens! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.