API Reference
Navigation Structure
Table of contents
Setup
init(token, options) => Undefined
Initalize SDK with API token and other options.
Parameters
Name | Type | Description |
---|---|---|
token | String | Tinybird API token |
options.debug | Boolean | flag for setting log level to debug |
options.’api-url’ | String | Custom 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
Name | Type | Description |
---|---|---|
sql | String | SQL 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']);