### Installing Tinybird CLI Source: https://tinybird.co/docs/forward/get-started/quick-start This command downloads and executes the Tinybird installation script, which installs the Tinybird CLI on your machine. It's the first step to set up your development environment. ```Shell curl https://tinybird.co | sh ``` -------------------------------- ### Installing Tinybird CLI (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start This command downloads and executes the Tinybird CLI installation script from the official Tinybird website. It's the first step to set up the Tinybird development environment. ```shell curl https://tinybird.co | sh ``` -------------------------------- ### Install Tinybird CLI Source: https://tinybird.co/docs/forward This shell command downloads and executes the Tinybird installation script, which sets up the Tinybird CLI on your system. It is the recommended first step to begin interacting with Tinybird from your terminal. ```shell curl https://tinybird.co | sh ``` -------------------------------- ### Install Tinybird CLI Source: https://tinybird.co/docs/forward/get-started/quick-start This shell command downloads and executes the Tinybird CLI installation script directly from the Tinybird website. It is the initial step required to set up your local Tinybird development environment and interact with Tinybird services. ```shell curl https://tinybird.co | sh ``` -------------------------------- ### Deploying Tinybird Project to Cloud Source: https://tinybird.co/docs/forward/get-started/quick-start This command deploys the current Tinybird project, including all defined datasources and pipes, to the Tinybird Cloud environment. The `--cloud` flag ensures that the resources are provisioned and made available in the cloud, transitioning from local development to a production-ready setup. ```Shell tb --cloud deploy ``` -------------------------------- ### Starting Tinybird Local Development Server Source: https://tinybird.co/docs/forward/get-started/quick-start This command starts the Tinybird local development server, allowing users to develop and test Tinybird pipes and datasources locally before deploying them. ```shell ``` -------------------------------- ### Starting Tinybird Local Instance Source: https://tinybird.co/docs/forward/get-started/quick-start This command starts a local Tinybird instance within a Docker container, enabling local development and testing of data projects before deployment to the Tinybird Cloud. It requires a container runtime like Docker or Orbstack. ```Shell tb local start ``` -------------------------------- ### Opening Tinybird Project in Cloud using CLI Source: https://tinybird.co/docs/forward/get-started/quick-start This command opens the current Tinybird project in the Tinybird Cloud UI, allowing users to view project details, monitor endpoints, and access statistics directly in their web browser. It requires the Tinybird CLI to be installed and authenticated. ```Shell tb --cloud open ``` -------------------------------- ### Installing Tinybird CLI using cURL Source: https://tinybird.co/docs/forward This command downloads and executes the Tinybird CLI installation script from the official Tinybird website. It's the primary method for setting up the CLI on a new machine. ```shell curl https://tinybird.co | sh ``` -------------------------------- ### Installing Tinybird CLI using cURL Source: https://tinybird.co/docs/forward This command downloads and executes the Tinybird CLI installation script from the official Tinybird website. It is the recommended method for installing the CLI on Linux or macOS systems, providing a streamlined setup process. ```Shell curl https://tinybird.co | sh ``` -------------------------------- ### Creating Local Environment File Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-nextjs This command copies the example environment file, `.env.example`, to `.env.local`. The `.env.local` file is used to store local environment variables that are specific to your development setup and are not committed to version control. ```Shell cp .env.example .env.local ``` -------------------------------- ### Creating Kafka Datasource with CLI Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This command initiates a guided process to create a Kafka connection and datasource in Tinybird. It simplifies the setup by prompting for necessary configuration details, streamlining the integration of Kafka data into Tinybird. ```Shell tb datasource create --kafka ``` -------------------------------- ### Starting Tinybird Development Server Source: https://tinybird.co/docs/forward/get-started/quick-start This command initiates the Tinybird local development server, which automatically rebuilds and reloads the project upon file changes. It also provides a console for interacting with the local database, facilitating rapid development and testing of data files and endpoints. ```Shell tb dev ``` -------------------------------- ### Starting Tinybird Local Instance Source: https://tinybird.co/docs/forward/get-started/quick-start This command initiates a Tinybird Local instance, running within a Docker container. It provides a local development environment for building and testing Tinybird projects without affecting your cloud workspace. ```Shell tb local start ``` -------------------------------- ### Starting Tinybird Local Instance (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start This command launches a local Tinybird instance within a Docker container, enabling developers to build and test their data projects in a local environment before deploying to the cloud. It requires a container runtime like Docker. ```shell tb local start ``` -------------------------------- ### Creating a Tinybird Project with CLI Source: https://tinybird.co/docs/forward/get-started/quick-start This command initializes a new Tinybird project, ingesting data from a specified URL and generating an initial project structure based on a natural language prompt. It sets up data sources, endpoints, and fixtures. ```Shell tb create \ --data "https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD" \ --prompt "Create an endpoint that ranks EV models. It should return all types by default, with optional type and limit parameters" ``` -------------------------------- ### Starting Tinybird Local Instance Source: https://tinybird.co/docs/forward This command starts a Tinybird Local instance within a Docker container. It allows developers to build and test their Tinybird projects locally, providing a development environment that mirrors the cloud without requiring immediate deployment. A container runtime like Docker or Orbstack is a prerequisite. ```Shell tb local start ``` -------------------------------- ### Copying Environment File for Local Configuration (Shell) Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-nextjs This shell command creates a local copy of the `.env.example` file, named `.env.local`. This practice allows developers to customize environment variables for their specific development setup without altering the version-controlled example file, ensuring sensitive information is not committed. ```Shell cp .env.example .env.local ``` -------------------------------- ### Deploying Project to Tinybird Cloud (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start This command deploys all project resources from your local environment to Tinybird Cloud. It uses the `--cloud` flag to specify the cloud deployment target, preparing all necessary resources. ```shell tb --cloud deploy ``` -------------------------------- ### Logging into Tinybird CLI Source: https://tinybird.co/docs/forward/get-started/quick-start This command initiates the login process for the Tinybird CLI, authenticating the user to access their Tinybird account and manage resources. ```shell tb login\n ``` -------------------------------- ### Deploying Project to Tinybird Cloud (Shell) Source: https://tinybird.co/docs/forward This command deploys the current Tinybird project to the Tinybird Cloud environment. The `--cloud` flag specifies the target environment, preparing all necessary resources for the project to run in the cloud. It's a crucial step for moving local development to a production-ready setup. ```shell tb --cloud deploy ``` -------------------------------- ### Starting Tinybird Local Instance Source: https://tinybird.co/docs/forward This command launches a local Tinybird instance within a Docker container, providing a development and testing environment for Tinybird projects. It requires a container runtime like Docker or Orbstack. ```shell tb local start ``` -------------------------------- ### Creating Kafka Data Source with Tinybird CLI Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This command initiates the creation of a new Kafka data source file (`.datasource`) using the Tinybird CLI. It streamlines the setup process by generating the initial configuration, though manual creation is also an option. This command is essential for integrating Kafka topics with Tinybird. ```Shell tb datasource create --kafka ``` -------------------------------- ### Running Tinybird Local Instance (Shell) Source: https://tinybird.co/docs/forward This command starts a Tinybird Local instance within a Docker container. It allows developers to build and test their Tinybird projects in a local environment before deployment. ```Shell tb local start ``` -------------------------------- ### Authenticating Tinybird CLI Source: https://tinybird.co/docs/forward/get-started/quick-start This command initiates the authentication process for the Tinybird CLI, opening a browser window to allow you to log in to your Tinybird account and select or create a workspace. ```Shell tb login ``` -------------------------------- ### Deploying Tinybird Project to Cloud (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start Deploys the current Tinybird project to the Tinybird cloud environment. This command pushes all local changes, including datasources and pipes, to the remote Tinybird workspace, making them accessible for production use. ```shell tb --cloud deploy ``` -------------------------------- ### Opening Project in Tinybird Cloud UI (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start This command opens your Tinybird project directly in the Tinybird Cloud user interface. It provides quick access to manage endpoints, view statistics, and explore snippets. ```shell tb --cloud open ``` -------------------------------- ### Copying Environment Configuration in Shell Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-nextjs This shell command copies the example environment file (`.env.example`) to a local environment file (`.env.local`). This is a common first step in setting up a project to customize environment variables without modifying the version-controlled example, ensuring local configurations are isolated. ```shell cp .env.example .env.local ``` -------------------------------- ### Creating a Tinybird Project with Data and Prompt (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start This command creates a new Tinybird project structure by providing a data source URL and a natural language prompt. The CLI uses the prompt to scaffold relevant data sources and endpoints, facilitating rapid project initialization with sample data. ```shell tb create \ --data "https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD" \ --prompt "Create an endpoint that ranks EV models. It should return all types by default, with optional type and limit parameters" ``` -------------------------------- ### Opening Tinybird Project in Cloud via CLI (Shell) Source: https://tinybird.co/docs/forward This command opens the current Tinybird project in the Tinybird Cloud UI, allowing users to view project details, endpoints, and statistics directly in their browser. It requires the Tinybird CLI to be installed and authenticated. ```Shell tb --cloud open ``` -------------------------------- ### Installing Tinybird CLI via Curl (Shell) Source: https://tinybird.co/docs/forward/dev-reference/commands/tb-update This snippet provides the shell command to install the Tinybird CLI using `curl`. It fetches the installation script from the Tinybird website and pipes it directly to `sh` for execution. This is a common and straightforward method for initial setup of the CLI. ```shell curl https://tinybird.co | sh ``` -------------------------------- ### Creating Tinybird Project Source: https://tinybird.co/docs/forward/get-started/quick-start This command generates a new Tinybird project in the current directory. It supports flags like --data to specify an input data file and --prompt to provide a natural language description for the project's desired structure and components. ```Shell tb create ``` -------------------------------- ### Starting Development Server with npm in Shell Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-nextjs This shell command initiates the development server for the application using `npm run dev`. It's a standard command for starting a local development environment, often used in Node.js or Next.js projects to enable live reloading and debugging during development. ```shell npm run dev ``` -------------------------------- ### Initialize Kafka Data Source with Tinybird CLI Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This command-line interface (CLI) utility initiates an interactive process to create a new data source in Tinybird, specifically configured to consume data from a Kafka topic. It guides the user through setting up the necessary .connection and .datasource files required for Kafka integration, simplifying the initial configuration. ```Shell tb datasource create --kafka ``` -------------------------------- ### Creating a Tinybird Project with CLI Source: https://tinybird.co/docs/forward This command initializes a new Tinybird project, ingesting data from a specified URL and generating an initial project structure based on the provided prompt. It sets up data sources, endpoints, and fixtures for an EV model ranking application. ```Bash tb create \\ --data \"https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD\" \\ --prompt \"Create an endpoint that ranks EV models. It should return all types by default, with optional type and limit parameters\" ``` -------------------------------- ### Creating a Tinybird Project with Data and Prompt Source: https://tinybird.co/docs/forward This command creates a new Tinybird project, ingesting data from a specified URL and using an AI-powered prompt to scaffold initial project resources like datasources and endpoints. It demonstrates how to quickly set up a project with external data and a defined objective. ```shell tb create \\ --data \"https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD\" \\ --prompt \"Create an endpoint that ranks EV models. It should return all types by default, with optional type and limit parameters\" ``` -------------------------------- ### Example JSON Output from Tinybird Local Query Source: https://tinybird.co/docs/forward/get-started/quick-start This JSON object represents the structured output from a query executed against Tinybird Local. It includes metadata about the columns, the actual data rows (showing vehicle make, model, type, and count), and statistics about the query execution, such as elapsed time and bytes read. ```json {\\n \\"meta\\":\\n [\\n {\\n \\"name\\": \\"make\\",\\n \\"type\\": \\"String\\"\\n },\\n {\\n \\"name\\": \\"model\\",\\n \\"type\\": \\"String\\"\\n },\\n {\\n \\"name\\": \\"electric_vehicle_type\\",\\n \\"type\\": \\"String\\"\\n },\\n {\\n \\"name\\": \\"vehicle_count\\",\\n \\"type\\": \\"UInt64\\"\\n }\\n ],\\n\\n \\"data\\":\\n [\\n {\\n \\"make\\": \\"TESLA\\",\\n \\"model\\": \\"MODEL Y\\",\\n \\"electric_vehicle_type\\": \\"Battery Electric Vehicle (BEV)\\",\\n \\"vehicle_count\\": 49588\\n },\\n {\\n \\"make\\": \\"TESLA\\",\\n \\"model\\": \\"MODEL 3\\",\\n \\"electric_vehicle_type\\": \\"Battery Electric Vehicle (BEV)\\",\\n \\"vehicle_count\\": 36085\\n },\\n {\\n \\"make\\": \\"NISSAN\\",\\n \\"model\\": \\"LEAF\\",\\n \\"electric_vehicle_type\\": \\"Battery Electric Vehicle (BEV)\\",\\n \\"vehicle_count\\": 13853\\n }\\n ],\\n\\n \\"rows\\": 3,\\n\\n \\"rows_before_limit_at_least\\": 175,\\n\\n \\"statistics\\":\\n {\\n \\"elapsed\\": 0.041374271,\\n \\"rows_read\\": 239183,\\n \\"bytes_read\\": 16906256\\n }\\n} ``` -------------------------------- ### Opening Tinybird Cloud Workspace (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start Opens the Tinybird cloud workspace associated with the current project in the default web browser. This provides quick access to the Tinybird UI for managing datasources, pipes, and monitoring project status. ```shell tb --cloud open ``` -------------------------------- ### Testing Tinybird Local API Endpoint with cURL Source: https://tinybird.co/docs/forward/get-started/quick-start This cURL command demonstrates how to make a GET request to a Tinybird local API endpoint. It uses the previously copied local token for authentication and includes a `limit` parameter to retrieve a specific number of results, showcasing how to interact with the deployed pipe. ```Shell curl -X GET "http://localhost:7181/v0/pipes/model_ranking.json?token=$TB_LOCAL_TOKEN&limit=3" ``` -------------------------------- ### Starting Tinybird Local Development (tb dev) Source: https://tinybird.co/docs/forward Initiates the Tinybird local development server, building project assets like datasources and pipes. This command allows developers to test and iterate on their Tinybird projects locally before deploying to the cloud. ```shell tb dev ``` -------------------------------- ### Authenticating Tinybird CLI (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start This command initiates the authentication process for the Tinybird CLI, prompting the user to log in via their browser to link their local CLI with their Tinybird Cloud account and select a workspace. ```shell tb login ``` -------------------------------- ### Running Tinybird Development Server Source: https://tinybird.co/docs/forward/get-started/quick-start This shell command initiates the Tinybird development server, which automatically builds the project and reloads changes upon file saving. It also provides a console for database interaction and displays the build status, including any errors like 'rows in quarantine' which can be disregarded during prototyping. ```Shell tb dev » Building project... ✓ datasources/rows.datasource created ✓ endpoints/rows_endpoint.pipe created ✓ endpoints/model_ranking.pipe created Error appending fixtures for 'rows': There was an error with file contents: 564 rows in quarantine. ✓ Build completed in 9.1s Watching for changes... tb » ``` -------------------------------- ### Basic Instruction Syntax in Tinybird Datafiles Source: https://tinybird.co/docs/forward/dev-reference/datafiles This example demonstrates the fundamental syntax for instructions within Tinybird datafiles. Instructions begin at the start of a line in uppercase, followed by their respective values. Values with multiple words are enclosed in double quotes. ```Tinybird Datafile Syntax COMMAND value ANOTHER_INSTR "Value with multiple words" ``` -------------------------------- ### Creating Kafka Connection using Tinybird CLI Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This command initiates an interactive process to create a new Kafka connection in Tinybird. It prompts the user for essential connection details such as the connection name, bootstrap server, Kafka key, and Kafka secret, streamlining the setup. ```Shell tb connection create kafka ``` -------------------------------- ### Authenticating Tinybird CLI Source: https://tinybird.co/docs/forward/get-started/quick-start This command authenticates the Tinybird CLI with your Tinybird account. Upon execution, it typically opens a browser window to complete the authentication flow and select a Tinybird workspace. ```Shell tb login ``` -------------------------------- ### Running Next.js Development Server Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-nextjs This command starts the Next.js development server locally. It compiles the application and makes it accessible in your browser, typically at `localhost:3000`, allowing for live reloads during development. ```Shell npm run dev ``` -------------------------------- ### Running Tinybird Local Development Server Source: https://tinybird.co/docs/forward This shell command initiates the Tinybird local development server, which automatically builds the project, watches for file changes, and provides a console for database interaction. The output shows the successful creation of data sources and endpoints, along with a common quarantine error for fixtures. ```Shell tb dev » Building project... ✓ datasources/rows.datasource created ✓ endpoints/rows_endpoint.pipe created ✓ endpoints/model_ranking.pipe created Error appending fixtures for 'rows': There was an error with file contents: 564 rows in quarantine. ✓ Build completed in 9.1s Watching for changes... tb » ``` -------------------------------- ### Running the Tinybird Local Development Server (CLI) Source: https://tinybird.co/docs/forward This command initiates the Tinybird local development server, which automatically rebuilds and reloads the project upon file changes. It also provides a console for database interaction, facilitating rapid prototyping and development. ```Shell tb dev ``` -------------------------------- ### Validating Kafka Connection and Datasource Deployment Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This command performs a deployment check, validating the Kafka broker's reachability and Tinybird's ability to connect using the provided credentials. It is crucial for verifying the setup before a full deployment, especially after setting new secrets. ```bash tb --cloud deploy --check ``` -------------------------------- ### Deploying Tinybird Project to Cloud Source: https://tinybird.co/docs/forward Deploys the current Tinybird project from the local environment to the Tinybird cloud. This command synchronizes local changes with the remote Tinybird workspace, making pipes and datasources available in the cloud. ```shell tb --cloud deploy ``` -------------------------------- ### Authenticating Tinybird CLI Source: https://tinybird.co/docs/forward This command initiates the authentication process for the Tinybird CLI, opening a browser window to allow the user to log in to their Tinybird account or select an existing workspace. ```shell tb login ``` -------------------------------- ### Creating Kafka Connection via Tinybird CLI (Bash) Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This `bash` command demonstrates the initial step of creating a Kafka connection using the Tinybird CLI. It is the recommended method for establishing robust connectivity between your Tinybird workspace and a Kafka cluster, facilitating data ingestion. ```Bash tb connection create kaf ``` -------------------------------- ### Creating Tinybird Project with AI (Shell) Source: https://tinybird.co/docs/forward This command initializes a new Tinybird project, leveraging AI to generate project structure. It requires specifying input data via the --data flag and providing a natural language prompt using the --prompt flag to define the desired project outcome. ```Shell tb create ``` ```Shell --data ``` ```Shell --prompt ``` -------------------------------- ### Getting `tumbleStart` of a Window in Tinybird SQL Source: https://tinybird.co/docs/sql-reference/functions/time-window-functions This snippet illustrates how to use the `tumbleStart` function to retrieve the inclusive lower bound of a tumbling time window. It's useful for identifying the start time of a specific window. The example calculates the start of a 1-day tumbling window from the current timestamp. ```SQL SELECT tumbleStart(now(), toIntervalDay('1')) ``` -------------------------------- ### Deploying Project to Tinybird Cloud (CLI) Source: https://tinybird.co/docs/forward This command deploys the current Tinybird project, including all defined datasources and pipes, to the Tinybird Cloud environment. The '--cloud' flag ensures that the deployment targets the cloud instance rather than the local development server. ```Shell tb --cloud deploy ``` -------------------------------- ### Running Next.js Development Server (JavaScript) Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-nextjs This `npm` command starts the Next.js development server, making the application accessible locally, typically at `localhost:3000`. It enables features like hot-reloading and provides a development-friendly environment for building and testing the application. ```JavaScript npm run dev ``` -------------------------------- ### Sample Electric Vehicle Data CSV Source: https://tinybird.co/docs/forward/get-started/quick-start This CSV snippet provides a sample of electric vehicle data, intended for local testing within the Tinybird project. It includes a header row defining the columns and several example data rows, demonstrating the structure and content of the 'rows.csv' fixture file. ```CSV VIN (1-10),County,City,State,Postal Code,Model Year,Make,Model,Electric Vehicle Type,Clean Alternative Fuel Vehicle (CAFV) Eligibility,Electric Range,Base MSRP,Legislative District,DOL Vehicle ID,Vehicle Location,Electric Utility,2020 Census Tract 1C4JJXP68P,Yakima,Yakima,WA,98901,2023,JEEP,WRANGLER,Plug-in Hybrid Electric Vehicle (PHEV),Not eligible due to low battery range,21,0,15,249905295,POINT (-120.50729 46.60464),PACIFICORP,53077001601 1G1FY6S03L,Kitsap,Kingston,WA,98346,2020,CHEVROLET,BOLT EV,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,259,0,23,141133765,POINT (-122.4977 47.79802),PUGET SOUND ENERGY INC,53035940000 KNDCE3LG9K,King,Seattle,WA,98125,2019,KIA,NIRO,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,239,0,46,3410074,POINT (-122.30253 47.72656),CITY OF SEATTLE - (WA)|CITY OF TACOMA - (WA),53033000101 1N4AZ0CP8E,Thurston,Olympia,WA,98506,2014,NISSAN,LEAF,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,84,0,22,182436474,POINT (-122.87741 47.05997),PUGET SOUND ENERGY INC,53067012100 5YJXCAE29L,Kitsap,Silverdale,WA,98383,2020,TESLA,MODEL X,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,293,0,23,1843054,POINT (-122.69275 47.65171),PUGET SOUND ENERGY INC,53035091206 ``` -------------------------------- ### Appending Data to Tinybird Cloud Datasource (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start This command ingests data from a specified URL into a Tinybird Cloud datasource. The `--cloud` flag ensures the operation targets the cloud environment, and `--url` provides the source of the CSV data. ```shell tb --cloud datasource append rows --url \"https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD\" ``` -------------------------------- ### Using tb_secret() for Kafka Key in Tinybird Connection File Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This example demonstrates using the `tb_secret()` function within a Tinybird connection file (`.connection`) to securely manage the `KAFKA_KEY`. It retrieves the secret from the environment or uses a provided default value (`kafka-local-username`) if not found. ```Tinybird Connection File KAFKA_KEY {{ tb_secret("KAFKA_KEY", "kafka-local-username") }} ``` -------------------------------- ### Using tb_secret for Kafka Connection in Tinybird Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This example demonstrates using the `tb_secret()` function within a Tinybird `.connection` file to securely manage Kafka authentication keys. It allows fetching secrets from the Tinybird environment or providing a default fallback value if the secret is not found. ```Tinybird Configuration KAFKA_KEY {{ tb_secret("KAFKA_KEY", "kafka-local-username") }} ``` -------------------------------- ### Creating Kafka Connection via Tinybird CLI Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This command initiates an interactive process to create a new Kafka connection in Tinybird. Users will be prompted to provide a connection name, bootstrap server, Kafka key, and Kafka secret. It is the recommended method for setting up a basic connection. ```bash tb connection create kafka ``` -------------------------------- ### Tinybird Basic Syntax Example Source: https://tinybird.co/docs/forward/dev-reference/datafiles This example demonstrates the basic syntactic conventions for Tinybird datafiles, where instructions appear at the beginning of a line in uppercase, followed by their values. It also shows how string values with multiple words are enclosed in double quotes. ```tb COMMAND value ANOTHER_INSTR "Value with multiple words" ``` -------------------------------- ### Copying Token and Querying Local Pipe (Shell) Source: https://tinybird.co/docs/forward/get-started/quick-start Copies a Tinybird admin token to the clipboard and then uses it to query a local Tinybird pipe (`model_ranking.json`) via `curl`. This demonstrates how to authenticate and retrieve data from a locally running Tinybird instance, specifying a limit for the results. ```shell tb token copy "admin local_testing@tinybird.co" && TB_LOCAL_TOKEN=$(pbpaste) curl -X GET "http://localhost:7181/v0/pipes/model_ranking.json?token=$TB_LOCAL_TOKEN&limit=3" ``` -------------------------------- ### Authenticating Tinybird CLI Source: https://tinybird.co/docs/forward This command initiates the authentication process for the Tinybird CLI. Upon execution, it opens a browser window, prompting the user to log in to their Tinybird account and select an existing workspace or create a new one to link with the CLI. ```Shell tb login ``` -------------------------------- ### Sample Data for Tinybird Project Fixtures Source: https://tinybird.co/docs/forward/get-started/quick-start This CSV snippet provides sample data for the `rows.csv` fixture file, used for local testing and development within the Tinybird project. It includes various columns related to electric vehicle population data. ```CSV VIN (1-10),County,City,State,Postal Code,Model Year,Make,Model,Electric Vehicle Type,Clean Alternative Fuel Vehicle (CAFV) Eligibility,Electric Range,Base MSRP,Legislative District,DOL Vehicle ID,Vehicle Location,Electric Utility,2020 Census Tract 1C4JJXP68P,Yakima,Yakima,WA,98901,2023,JEEP,WRANGLER,Plug-in Hybrid Electric Vehicle (PHEV),Not eligible due to low battery range,21,0,15,249905295,POINT (-120.50729 46.60464),PACIFICORP,53077001601 1G1FY6S03L,Kitsap,Kingston,WA,98346,2020,CHEVROLET,BOLT EV,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,259,0,23,141133765,POINT (-122.4977 47.79802),PUGET SOUND ENERGY INC,53035940000 KNDCE3LG9K,King,Seattle,WA,98125,2019,KIA,NIRO,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,239,0,46,3410074,POINT (-122.30253 47.72656),CITY OF SEATTLE - (WA)|CITY OF TACOMA - (WA),53033000101 1N4AZ0CP8E,Thurston,Olympia,WA,98506,2014,NISSAN,LEAF,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,84,0,22,182436474,POINT (-122.87741 47.05997),PUGET SOUND ENERGY INC,53067012100 5YJXCAE29L,Kitsap,Silverdale,WA,98383,2020,TESLA,MODEL X,Battery Electric Vehicle (BEV),Clean Alternative Fuel Vehicle Eligible,293,0,23,1843054,POINT (-122.69275 47.65171),PUGET SOUND ENERGY INC,53035091206 ``` -------------------------------- ### Example JSON Output from Tinybird Local Query Source: https://tinybird.co/docs/forward This JSON snippet represents the typical output structure when querying data from Tinybird Local. It includes metadata about the columns, the actual data rows, and statistics about the query execution, such as elapsed time and bytes read. This output demonstrates the schema and data format returned by Tinybird queries. ```json { "meta": [ { "name": "make", "type": "String" }, { "name": "model", "type": "String" }, { "name": "electric_vehicle_type", "type": "String" }, { "name": "vehicle_count", "type": "UInt64" } ], "data": [ { "make": "TESLA", "model": "MODEL Y", "electric_vehicle_type": "Battery Electric Vehicle (BEV)", "vehicle_count": 49588 }, { "make": "TESLA", "model": "MODEL 3", "electric_vehicle_type": "Battery Electric Vehicle (BEV)", "vehicle_count": 36085 }, { "make": "NISSAN", "model": "LEAF", "electric_vehicle_type": "Battery Electric Vehicle (BEV)", "vehicle_count": 13853 } ], "rows": 3, "rows_before_limit_at_least": 175, "statistics": { "elapsed": 0.041374271, "rows_read": 239183, "bytes_read": 16906256 } } ``` -------------------------------- ### Running Tinybird Development Server (CLI) Source: https://tinybird.co/docs/forward This command initializes the Tinybird development server, enabling users to edit data files directly within their project directory. It provides a console for interacting with the database and automatically rebuilds and reloads the project upon saving any file changes, significantly streamlining the development process. ```CLI tb dev ``` -------------------------------- ### Example Tinybird Environment Variables for .env File in Shell Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-nextjs This shell snippet demonstrates the structure for configuring Tinybird API credentials and workspace details within a `.env` file. It specifies variables like `TINYBIRD_SIGNING_TOKEN`, `TINYBIRD_WORKSPACE`, and `NEXT_PUBLIC_TINYBIRD_HOST` for connecting to the Tinybird platform. ```shell TINYBIRD_SIGNING_TOKEN="YOUR SIGNING TOKEN" TINYBIRD_WORKSPACE="YOUR WORKSPACE ID" NEXT_PUBLIC_TINYBIRD_HOST="YOUR API HOST e.g. https://api.tinybird.co" ``` -------------------------------- ### Installing Tinybird CLI Source: https://tinybird.co/docs/forward/get-started/learn This command installs the Tinybird Command Line Interface (CLI) by downloading and executing a shell script from the Tinybird website. It is a prerequisite for developing with Tinybird, enabling interaction with the Tinybird platform from your local environment. ```Shell curl https://tinybird.co | sh ``` -------------------------------- ### Opening Project in Tinybird Cloud UI (Shell) Source: https://tinybird.co/docs/forward This command opens the current Tinybird project directly in the Tinybird Cloud user interface within your default web browser. The `--cloud` flag ensures the correct environment is targeted, providing quick access to project details, endpoints, and statistics in the cloud console. ```shell tb --cloud open ``` -------------------------------- ### Starting Local Tinybird Development Environment Source: https://tinybird.co/docs/forward/install-tinybird/migrate This snippet shows commands to start the local Tinybird container for development and to build the project in watch mode, allowing for continuous development and testing. ```bash # Start the local container\ntb local start\n\n# Build your project in watch mode\ntb dev\n ``` -------------------------------- ### Example of overlay Function in SQL (Replacement with Length) Source: https://tinybird.co/docs/sql-reference/functions/string-replace-functions This example illustrates using the `overlay` function with the optional `length` parameter. It replaces 6 characters starting from the 4th position in 'My father is from Mexico.' with 'dad', resulting in 'My dad is from Mexico.'. ```SQL SELECT overlay('My father is from Mexico.', 'dad', 4, 6) AS res ``` -------------------------------- ### Installing Tinybird CLI Source: https://tinybird.co/docs/forward/get-started/learn This command installs the Tinybird Command Line Interface (CLI) by downloading an installation script via `curl` and executing it with `sh`. The Tinybird CLI is essential for interacting with Tinybird Cloud, including defining data ingestion, creating API endpoints, and deploying data projects. ```Shell curl https://tinybird.co | sh ``` -------------------------------- ### Configuring Kafka Cloud Secrets in .env.local Source: https://tinybird.co/docs/forward/get-data-in/connectors/kafka This snippet demonstrates how to securely configure Kafka server credentials for a cloud environment within a local setup. It uses a `.env.local` file to store `KAFKA_KEY` and `KAFKA_SECRET`, preventing exposure of sensitive information in code. ```Shell KAFKA_KEY="kafka-cloud-username" KAFKA_SECRET="kafka-cloud-password" ``` -------------------------------- ### Extracting Bit Slices with bitSlice Function in SQL Source: https://tinybird.co/docs/sql-reference/functions/bit-functions These SQL queries illustrate the `bitSlice` function, which extracts a substring based on bit offset and length. Examples show extracting 8 bits from the start, 2 bits from the start (with padding), 9 bits from the start (with truncation/padding), and 8 bits from a negative offset, demonstrating various usage patterns and edge cases. ```SQL select bin('Hello'), bin(bitSlice('Hello', 1, 8)) ``` ```SQL select bin('Hello'), bin(bitSlice('Hello', 1, 2)) ``` ```SQL select bin('Hello'), bin(bitSlice('Hello', 1, 9)) ``` ```SQL select bin('Hello'), bin(bitSlice('Hello', -4, 8)) ``` -------------------------------- ### Example of overlay Function in SQL (Basic Replacement) Source: https://tinybird.co/docs/sql-reference/functions/string-replace-functions This example demonstrates the basic usage of the `overlay` function. It replaces 'father' with 'mother' in the input string 'My father is from Mexico.', starting at the 4th character. The function returns the modified string 'My mother is from Mexico.'. ```SQL SELECT overlay('My father is from Mexico.', 'mother', 4) AS res ``` -------------------------------- ### Testing Tinybird API Endpoint with cURL Source: https://tinybird.co/docs/forward This snippet demonstrates how to test the locally hosted Tinybird API endpoint using cURL. It first copies the local admin token and then uses it to authenticate the GET request to the 'model_ranking.json' endpoint, passing a 'limit' parameter for a smaller response. ```Shell tb token copy \"admin local_testing@tinybird.co\" && TB_LOCAL_TOKEN=$(pbpaste) curl -X GET \"http://localhost:7181/v0/pipes/model_ranking.json?token=$TB_LOCAL_TOKEN&limit=3\" ``` -------------------------------- ### Example Parameters for Tinybird Infrastructure Initialization Source: https://tinybird.co/docs/forward/install-tinybird/self-managed/assisted These are illustrative examples of the values required when running the tb infra init command, specifying the AWS region, DNS zone name, and DNS record name for the Tinybird deployment. ```Shell us-east-1 ``` ```Shell example.com ``` ```Shell tinybird ``` -------------------------------- ### Example of overlayUTF8 Function in SQL Source: https://tinybird.co/docs/sql-reference/functions/string-replace-functions This example demonstrates the `overlayUTF8` function's usage with a string containing special UTF-8 characters. It replaces a part of 'Mein Vater ist aus Österreich.' with 'der Türkei' starting at the 20th character, correctly handling the multi-byte characters. ```SQL SELECT overlay('Mein Vater ist aus Österreich.', 'der Türkei', 20) AS res ``` -------------------------------- ### Testing Tinybird API Endpoint with cURL Source: https://tinybird.co/docs/forward/get-started/quick-start This shell command demonstrates how to test the Tinybird API endpoint 'model_ranking.json' locally using cURL. It first copies the local admin token and then uses it to make a GET request to the endpoint, passing a 'limit' parameter to control the response size. ```Shell tb token copy "admin local_testing@tinybird.co" && TB_LOCAL_TOKEN=$(pbpaste) curl -X GET "http://localhost:7181/v0/pipes/model_ranking.json?token=$TB_LOCAL_TOKEN" ``` -------------------------------- ### Managing Local Project Setup - Tinybird CLI (Shell) Source: https://tinybird.co/docs/forward/get-data-in/guides/ingest-from-snowflake-using-azure-blob-storage This command manages the local Tinybird project setup, including initializing new projects or linking to existing ones. ```Shell tb local ``` -------------------------------- ### Starting Tinybird Local Container Source: https://tinybird.co/docs/forward/install-tinybird/migrate This command initializes and starts the Tinybird local container, which is essential for local development and testing of your Tinybird project before deployment. ```Shell tb local start ``` -------------------------------- ### Installing Tinybird Forward CLI Source: https://tinybird.co/docs/forward/install-tinybird/migrate This command downloads and executes the Tinybird Forward CLI installation script from the official Tinybird website. It's the primary method for setting up the Forward CLI and the Tinybird Local container. ```bash curl https://tinybird.co | sh ``` -------------------------------- ### Authenticating Tinybird CLI (Shell) Source: https://tinybird.co/docs/forward This command authenticates the Tinybird CLI with your Tinybird account. Running it typically opens a browser window to complete the login process. ```Shell tb login ``` -------------------------------- ### API Parameter: 'limit' Source: https://tinybird.co/docs/forward The `limit` parameter is used in API calls to control the number of records returned, allowing for smaller responses, such as 3 records for testing purposes. ```HTTP limit ``` -------------------------------- ### Default Local URL for Tinybird Dev Server Source: https://tinybird.co/docs/forward This is the default URL used to access the Tinybird local development server, enabling local interaction with the project. ```Plain Text http://localhost:7181 ``` -------------------------------- ### Creating a Test Suite with Prompt for Tinybird Pipe Source: https://tinybird.co/docs/forward/test-and-deploy/test-your-project This command extends the `tb test create` functionality by using the `--prompt` flag to provide additional context for test data generation. It instructs the system to create a test suite for `user_action_insights_widget` that specifically focuses on user actions filtered by "CLICKED". ```Shell tb test create user_action_insights_widget --prompt "return user actions filtering by CLICKED" ``` -------------------------------- ### Copying Tinybird CLI Token Source: https://tinybird.co/docs/forward The `tb token copy` command copies the current Tinybird authentication token to the clipboard, which is essential for authenticating API calls from external applications. ```Shell tb token copy ``` -------------------------------- ### Example Tinybird Test Suite Configuration Source: https://tinybird.co/docs/forward/test-and-deploy/test-your-project This YAML snippet defines a test case within a Tinybird test suite. It specifies the test name, a descriptive explanation, the query parameters to be used (`action=CLICKED`), and the `expected_result` as a multi-line JSON string, which should match the endpoint's response for the given parameters. ```YAML - name: user_action_insights_widget_clicked description: Test the endpoint that returns user actions filtering by CLICKED parameters: action=CLICKED expected_result: | {"action":"CLICKED", "user_id":1, "timestamp":"2025-03-19T01:58:31Z"} {"action":"CLICKED", "user_id":2, "timestamp":"2025-03-20T05:34:22Z"} {"action":"CLICKED", "user_id":3, "timestamp":"2025-03-21T19:21:34Z"} ``` -------------------------------- ### Replacing Substring with overlay in SQL (With Length) Source: https://tinybird.co/docs/sql-reference/functions/string-replace-functions This SQL snippet illustrates the `overlay` function's usage with an explicit `length` parameter. It replaces a specified number of bytes from the input string starting at a 1-based offset. The example replaces 6 bytes (corresponding to 'father') with 'dad' starting at the 4th character, resulting in 'My dad is from Mexico.'. ```SQL SELECT overlay('My father is from Mexico.', 'dad', 4, 6) AS res ``` -------------------------------- ### Preparing Tinybird Cloud Resources (Shell) Source: https://tinybird.co/docs/forward/test-and-deploy/deployments/cli This shell command initiates the preparation of all necessary resources for a Tinybird Cloud deployment. The `--wait` flag ensures that the command will block execution until all resources are fully provisioned and ready for use, guaranteeing a stable environment. ```shell # Prepares all resources in Tinybird Cloud tb --cloud deployment create --wait ``` -------------------------------- ### Installing Tinybird CLI using uvx Source: https://tinybird.co/docs/forward/install-tinybird/migrate This snippet shows how to install both the Tinybird Classic CLI and the newer Tinybird Forward CLI using the `uvx` tool, specifying the package source. ```bash # For Classic CLI\nuvx --from tinybird-cli tb\n\n# For Forward CLI\nuvx --from tinybird tb\n ``` -------------------------------- ### Opening Tinybird Cloud Workspace Source: https://tinybird.co/docs/forward Opens the Tinybird cloud workspace in the default web browser. This provides quick access to the Tinybird UI for managing datasources, pipes, and other project components in the cloud. ```shell tb --cloud open ``` -------------------------------- ### Appending Data to Cloud Datasource Source: https://tinybird.co/docs/forward Appends data from a specified URL to a Tinybird datasource in the cloud. This command is used for ingesting external data into a Tinybird datasource, making it available for querying and analysis. ```shell tb --cloud datasource append rows --url "https://data.wa.gov/api/views/f6w7-q2d2/rows.csv?accessType=DOWNLOAD" ``` -------------------------------- ### Default Admin Token for Tinybird Local Testing Source: https://tinybird.co/docs/forward This string represents the default admin token for Tinybird's local testing environment, granting administrative permissions for local operations. ```Plain Text admin local_testing@tinybird.co ``` -------------------------------- ### Viewing Help for Tinybird Data Source Creation (Shell) Source: https://tinybird.co/docs/forward/get-data-in/data-sources This command displays the help documentation for the `tb datasource create` command, listing all available options and data source types. It's useful for quickly referencing command syntax and parameters. ```Shell tb datasource create -h ``` -------------------------------- ### API endpoint wiki_stream_example Source: https://tinybird.co/docs/forward/work-with-data/publish-data/guides/consume-apis-in-a-notebook This SQL snippet defines an API endpoint ('wiki_stream_example') designed for streaming data. It filters the 'wiki' data source by a date range defined by 'date_start' and 'date_end' parameters, and then further filters by a batch-specific timestamp range. ```SQL % SELECT * from wiki --DATE RANGE WHERE timestamp BETWEEN toUInt64(toDateTime({{String(date_start, '2022-02-13 10:30:00', description="start")}})) AND toUInt64(toDateTime({{String(date_end, '2022-02-13 10:35:00', description="end")}})) --BATCH BEGIN AND timestamp BETWEEN toUInt64(toDateTime({{String(date_start, '2022-02-13 10:30:00', description="st ``` -------------------------------- ### Example Tinybird Project File Structure Source: https://tinybird.co/docs/forward/dev-reference/datafiles This snippet illustrates the typical directory and file organization within a Tinybird project. It shows common folders like `datasources`, `endpoints`, `fixtures`, and `infra`, along with example files such as `.datasource` and `.pipe` files, providing a clear overview of project layout. ```Filesystem Structure . ├── .tinyb ├── connections ├── copies ├── datasources │ └── user_actions.datasource ├── endpoints │ ├── user_actions_line_chart.pipe │ └── user_actions_total_widget.pipe ├── fixtures │ ├── user_actions.prompt │ └── user_actions_d1046873.ndjson ├── infra │ └── aws │ ├── config.json │ ├── k8s.yaml │ └── main.tf ├── materializations ├── pipes └── tests └── user_actions_line_chart.yaml ``` -------------------------------- ### Deploying Tinybird Projects Source: https://tinybird.co/docs/forward/install-tinybird/migrate This snippet provides commands for deploying a Tinybird project, optionally to a local Tinybird instance for validation, and then to the Tinybird Cloud environment. ```bash # Optional: deploy to Tinybird Local to validate your project locally\ntb deploy\n\n# Deploy to Tinybird Cloud\ntb --cloud deploy\n ``` -------------------------------- ### Sample .tinyb Configuration File (JSON) Source: https://tinybird.co/docs/forward/dev-reference/datafiles/tinyb-file This snippet provides an example of a .tinyb file, which is a JSON configuration used by Tinybird. It includes placeholders for host, workspace ID, name, scope, authentication tokens, user email, user ID, user token, and version. This file is essential for configuring access to Tinybird resources. ```JSON { "host": "", "id": "", "name": "", "scope": "user", "token": "", "tokens": { "": "", "": "" }, "user_email": "", "user_id": "", "user_token": "", "version": "" } ``` -------------------------------- ### Example Output: tumble function (Text Console) Source: https://tinybird.co/docs/sql-reference/functions/time-window-functions Shows the expected output format for the `tumble` function when applied to `now()` with a 1-day interval. The output is a tuple representing the start and end timestamps of the tumbling window. ```text ┌─tumble(now(), toIntervalDay('1'))─────────────┐ │ ('2024-07-04 00:00:00','2024-07-05 00:00:00') │ └───────────────────────────────────────────────┘ ``` -------------------------------- ### Installing Tinybird Python SDK for AI Source: https://tinybird.co/docs/forward/get-data-in/guides/ingest-litellm This bash command installs the Tinybird Python SDK with the 'ai' extra, which includes necessary dependencies for integrating with AI frameworks like LiteLLM. This is a prerequisite for using Tinybird's LiteLLM handler. ```bash pip install tinybird-python-sdk[ai] ``` -------------------------------- ### Example of uniqThetaIntersect in Tinybird Source: https://tinybird.co/docs/sql-reference/functions/uniqtheta-functions This SQL query demonstrates how to use `uniqThetaIntersect` to find the intersection of two `uniqThetaSketch` values (`a` and `b`) and then finalize the aggregation to get the cardinality of the intersection. It initializes sketches `a` with `{1,2}` and `b` with `{2,3,4}`. ```Tinybird select finalizeAggregation(uniqThetaIntersect(a, b)) as a_intersect_b, finalizeAggregation(a) as a_cardinality, finalizeAggregation(b) as b_cardinality from (select arrayReduce('uniqThetaState',[1,2]) as a, arrayReduce('uniqThetaState',[2,3,4]) as b ) ``` -------------------------------- ### Displaying Tinybird Data Source Create Help Source: https://tinybird.co/docs/forward/get-data-in/data-sources This command displays the help documentation for the `tb datasource create` command, listing all available options and data source types. It provides a quick reference for users on how to use the command effectively. ```Shell tb datasource create -h ```