Overview

Understanding the RestBI SDK

The RestBI SDK serves as a bridge between your application and the backend service, allowing you to easily interact with the server, send queries, and retrieve data in a structured format. The SDK abstracts away the complexities of constructing and sending HTTP requests, handling responses, and managing data types, providing a simple and intuitive interface for developers.

Key Features

  • TypeScript Support: The SDK is written in TypeScript, ensuring type safety and providing IntelliSense support in your development environment.

  • Simple API: The SDK provides a straightforward API for sending queries and retrieving results, minimizing the need for boilerplate code.

  • Extensible: The SDK is designed to be extensible, allowing for the addition of custom functions and utilities as your application evolves.

Installation

Before using the SDK, you need to install it via npm:

npm install restbi-sdk

Basic Usage

Here's a quick example of how to use the SDK to send a query and retrieve results:

import { RestBIClient, Model, Query, SQLResult } from 'restbi-sdk'

// Define the model and query
const model: Model = {
    // Define your connection, tables, joins, etc.
    ...
};

const query: Query = {
    columns: ['Customer ID', 'Order Date', 'Total Due'],
    filters: [
        { column: 'OrderDate', operator: '>=', value: new Date('2023-01-01') },
        { column: 'OrderDate', operator: '<=', value: new Date('2023-12-31') }
    ],
    limit: 100
};

// Initialize the client and send the query
const client = new RestBIClient('http://localhost:3000');

client.executeQuery(model, query)
    .then((result: SQLResult) => {
        console.log('Query Results:', result);
    })
    .catch((error: Error) => {
        console.error('Error executing query:', error);
    });

Last updated