This article will explain how to use Python bindings for REST API.
Basic knowledge of Treasure Data, including the Toolbelt.
A table with some data. An example is provided in the TD Quickstart Guide guide.
Basic knowledge of our query language.
The Python bindings are released on PyPI as
td-client (stands for ‘T’reasure ‘D’ata). You can install the package from
The source code is available at GitHub.
List Databases and Tables
The example below lists the databases and tables. The API key is your authentication key.
The example below issues a query from a Python program. The query API is asynchronous — you can check for query completion by polling the job periodically (e.g. by issuing job.finished? calls).
job.result() does not put the job result into memory. It iterates through the rows in a streaming fashion.
If you would like to get result’s schema, you need to call
job.result_schema after job finished.
List and Get the Status of Jobs
The example below lists and gets the status of jobs.