Querying your data

The Query API allows you to interact with your pipes inside Tinybird Analytics, as if you were running SQL statements against a regular database. So if you have a pipe called ‘my_pipe’ you can do:

The hello world of SQL queries and Pipes
SELECT count() from my_pipe

Every resource in Tinybird Analytics is secured so in order to use the query API you must provide an Auth token with pipe read permissions. Check ‘PIPES:READ’ scope

Note that you could query more than one pipe at the same time (e.g. using a JOIN) so in that case the token must have read permissions for both pipes.

Remember that Pipe data can be accessed though the direct endpoint these two calls are equivalent

equivalent calls using Pipe API and Query API
 curl "https://api.tinybird.co/v0/sql?q=SELECT * FROM <pipe> FORMAT JSON"
 curl https://api.tinybird.co/v0/pipes/<pipe>.json

These two are equivalent as well

equivalent calls using Pipe API and Query API
 curl "https://api.tinybird.co/v0/sql?q=SELECT count() FROM <pipe> FORMAT JSON"
 curl "https://api.tinybird.co/v0/pipes/<pipe>.json?q=select count() from _"
GET /v0/sql
Running sql queries against your data
curl "https://api.tinybird.co/v0/sql?q=SELECT * FROM <pipe>"

Executes a SQL query using the engine and gives you the query metadata, the resulting data and some performance statistics

Succesfull response
"meta": [
        "name": "VendorID",
        "type": "Int32"
        "name": "tpep_pickup_datetime",
        "type": "DateTime"
"data": [
        "VendorID": 2,
        "tpep_pickup_datetime": "2001-01-05 11:45:23",
        "tpep_dropoff_datetime": "2001-01-05 11:52:05",
        "passenger_count": 5,
        "trip_distance": 1.53,
        "RatecodeID": 1,
        "store_and_fwd_flag": "N",
        "PULocationID": 71,
        "DOLocationID": 89,
        "payment_type": 2,
        "fare_amount": 7.5,
        "extra": 0.5,
        "mta_tax": 0.5,
        "tip_amount": 0,
        "tolls_amount": 0,
        "improvement_surcharge": 0.3,
        "total_amount": 8.8
        "VendorID": 2,
        "tpep_pickup_datetime": "2002-12-31 23:01:55",
        "tpep_dropoff_datetime": "2003-01-01 14:59:11"
"rows": 3,
"rows_before_limit_at_least": 4,
        "elapsed": 0.00091042,
        "rows_read": 4,
        "bytes_read": 296

Data can be fetched in different formats (JSON, CSV, CSVWithNames, TSV, TSVWithNames, PrettyCompact) just append FORMAT <format_name> to your SQL query:

Requesting different formats with SQL
SELECT count() from <pipe> FORMAT JSON