SDK around Tinybird APIs.
If you want to manage Workspaces, Data Sources and Pipes you might be looking for the tinybird-cli.
The SDK is meant to programatically ingest NDJSON data or send any request to an API instance.
from tb.datasource import Datasource
with Datasource(datasource_name, token) as ds:
ds << {'key': 'value', 'key1': 'value1'}from tb.datasource import Datasource
with Datasource(datasource_name, token, api_url='https://api.us-east.tinybird.co') as ds:
ds << {'key': 'value', 'key1': 'value1'}Alternatively you can do:
from tb.datasource import Datasource
ds = Datasource(datasource_name, token)
for json_obj in list_of_json:
ds << json_obj
# just remember to flush the remaining json_obj at the end
ds.flush()Notes:
- The
Datasourceobject does some in-memory buffering and uses the events API. - It only supports
ndjsondata - It automatically handles Rate Limits
from tb.api import API
api = API(token, api_url)
api.post('/v0/datasources', params={
'name': 'datasource_name',
'mode': 'append',
'format': 'ndjson',
'url': 'https://storage.googleapis.com/davidm-wadus/events.ndjson',
})- It automatically handle Rate Limits
- Works with any Tinybird API
- The
post,get,sendmethods signatures are equivalent to the requests library.