Querying your data

The Query API allows you to query your Pipes inside Tinybird Analytics as if you were running SQL statements against a regular database.

Using the Query API
 curl "https://api.tinybird.co/v0/sql?q=SELECT * FROM <pipe> FORMAT JSON"
 # or
 curl "https://api.tinybird.co/v0/pipes/<pipe>.json?q=select count() from _"

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.

GET /v0/sql

Executes a SQL query using the engine.

Running sql queries against your data
curl "https://api.tinybird.co/v0/sql?q=SELECT * FROM <pipe>"

As a response, it gives you the query metadata, the resulting data and some performance statistics.

Successful 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,
"statistics":
    {
        "elapsed": 0.00091042,
        "rows_read": 4,
        "bytes_read": 296
    }
}

Data can be fetched in many different formats. Just append FORMAT <format_name> to your SQL query:

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

Key

Type

Description

q

String

The SQL query

pipeline

String

(Optional) The name of the pipe. It allows to writing a query like ‘SELECT * FROM _’ where ‘_’ is a placeholder for the ‘pipeline’ parameter

Available formats

format

Description

CSV

CSV without header

CSVWithNames

CSV with header

JSON

JSON including data, statistics and schema information

TSV

TSV without header

TSVWithNames

TSV with header

PrettyCompact

Formatted table