Client for Keboola Storage API
Actively maintained. Last release 8 weeks ago. A safe choice.
pip install kbcstoragePython client for the Keboola Storage API
Client for using Keboola Connection Storage API. This API client provides client methods to get data from KBC and store data in KBC. The endpoints for working with buckets, tables and workspaces are covered.
Install
pip install kbcstorage
or
pip install git+https://github.com/keboola/sapi-python-client.git
Client Class Usage
from kbcstorage.client import Client, StorageApiToken
client = Client('https://connection.keboola.com', StorageApiToken('your-token'))
# get table data into local file
client.tables.export_to_file(table_id='in.c-demo.some-table', path_name='/data/')
# save data
client.tables.create(name='some-table-2', bucket_id='in.c-demo', file_path='/data/some-table')
# list buckets
client.buckets.list()
# list bucket tables
client.buckets.list_tables('in.c-demo')
# get table info
client.tables.detail('in.c-demo.some-table')
Authentication
The token argument takes an authentication strategy, either StorageApiToken or BearerToken:
from kbcstorage.client import Client, BearerToken, StorageApiToken
# Storage API token, sent as `X-StorageApi-Token`
client = Client('https://connection.keboola.com', StorageApiToken('your-token'))
# Programmatic token, sent as `Authorization: Bearer` with the project id in `X-KBC-ProjectId`
client = Client('https://connection.keboola.com', BearerToken('kbc_at_...', project_id=1234))
A bare string is also accepted and is equivalent to StorageApiToken('your-token'). It is fully
supported and not deprecated:
client = Client('https://connection.keboola.com', 'your-token')
Storage API tokens are bound to a project. Programmatic tokens (kbc_at_* session tokens,
kbc_pat_* personal access tokens) are not, which is why BearerToken requires the project id.
All three forms work for directly constructed endpoints too, and the token is used as given — the
client never refreshes or decodes it, so an expired token surfaces as a requests.HTTPError with a
401.