Skip to main content Link Search Menu Expand Document (external link)

API Reference

Table of contents

  1. Setup
    1. init(token, options) => Undefined
  2. Query
    1. query(sql) => Promise<Object>
  3. Datasources
  4. Pipes

Setup

init(token, options) => Undefined

Initalize SDK with API token and other options.

Parameters

NameTypeDescription
tokenStringTinybird API token
options.debugBooleanflag for setting log level to debug
options.’api-url’StringCustom tenant url. Defaults to https://api.tinybird.co

Example

import tb from 'tinybird-sdk';);

tb.init('p.eyJ1IjogIjZhNTdkYzFlCTM2ZTItNDNlYy04ZWRi...');

// You can also pass some options
tb.init('p.eyJ1IjogIjZhNTdkYzFlCTM2ZTItNDNlYy04ZWRi...', {
    debug: true
});

// If you have a custom installation
tb.init('p.eyJ1IjogIjZhNTdkYzFlCTM2ZTItNDNlYy04ZWRi...', {
    'api-url': 'https://my-tenant.tinybird.co'
});

Query

query(sql) => Promise<Object>

Query API endpoint and get resulting rows.

Parameters

NameTypeDescription
sqlStringSQL query, only SELECT is allowed.

Example

import tb from 'tinybird-sdk';

tb.init('p.eyJ1IjogIjZhNTdkYzFlCTM2ZTItNDNlYy04ZWRi...');

const result = await tb.query('select 1');
console.table(result['data']);

Datasources


Pipes


Copyright © 2022 Alejandro Martín. Distributed by an ISC license.