This article will explain how to use Ruby bindings for REST API.
Basic knowledge of Treasure Data, including the Toolbelt.
A table with some data. An example is provided in the What TD can do for you.
Basic knowledge of our query language.
Ruby 1.9 or newer
The Ruby bindings are included in the
td (stands for ‘T’reasure ‘D’ata) gem. Add the following line to your Gemfile.
The source code is available at GitHub.
List Databases and Tables
The following example lists the databases and tables. The API key is your authentication key.
The example below issues a query from a Ruby 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_each(&block) does not put the job result into memory. It iterates through the rows in a streaming fashion.
List and Get the Status of Jobs
The following example lists and gets the status of jobs.