Install the Tinybird CLI

You can install Tinybird on your local machine or use a prebuilt Docker image.

Read on to learn how to install and configure Tinybird CLI for use.

Installation

Install Tinybird CLI locally to use it on your machine.

Prerequisites

Tinybird CLI supports Linux and macOS 10.14 and higher.

Supported Python versions are 3.8, 3.9, 3.10, 3.11, 3.12.

Install tinybird-cli

Create a virtual environment before installing the tinybird-cli package:

Creating a virtual environment for Python 3
python3 -m venv .venv
source .venv/bin/activate

Then, install tinybird-cli:

Install tinybird-cli
pip install tinybird-cli

Docker image

The official tinybird-cli-docker image provides a Tinybird CLI executable ready to use in your projects and pipelines.

To run Tinybird CLI using Docker from the terminal, run the following commands:

Build local image setting your project path
# Assuming a projects/data path
docker run -v ~/projects/data:/mnt/data -it tinybirdco/tinybird-cli-docker
cd mnt/data

Authentication

Before you start using Tinybird CLI, check that you can authenticate by running tb auth:

Authenticate
tb auth -i

A list of available regions appears. Select your Tinybird region, then provide your admin Token. See Tokens.

You can also pass the Token directly with the --token flag. For example:

Authenticate
tb auth --token <your_admin_token>

See the API Reference docs for the list of supported regions. You can also get the list using tb auth ls.

The tb auth command saves your credentials in a .tinyb file in your current directory. Add it to your .gitignore file to avoid leaking credentials.

Integrated help

After you've installed the Tinybird CLI you can access the integrated help by using the --help flag:

Integrated help
tb --help

You can do the same for every available command. For example:

Integrated command help
tb datasource --help

Telemetry

Starting from version 1.0.0b272, the Tinybird CLI collects telemetry on the use of the CLI commands and information about exceptions and crashes and sends it to Tinybird. Telemetry helps Tinybird improve the command-line experience.

On each tb execution, the CLI collects information about your system, Python environment, the CLI version installed and the command you ran. All data is completely anonymous.

To opt out of the telemetry feature, set the TB_CLI_TELEMETRY_OPTOUT environment variable to 1 or true.

Configure your shell prompt

You can extract the current Tinybird Workspace and region from your .tinyb file and show it in your zsh or bash shell prompt.

To extract the information programmatically, paste the following function to your shell config file:

Parse the .tinyb file to use the output in the PROMPT
prompt_tb() {
if [ -e ".tinyb" ]; then
    TB_CHAR=$'\U1F423'
    branch_name=`grep '"name":' .tinyb | cut -d : -f 2 | cut -d '"' -f 2`
    region=`grep '"host":' .tinyb | cut -d / -f 3 | cut -d . -f 2 | cut -d : -f 1`
    if [ "$region" = "tinybird" ]; then
    region=`grep '"host":' .tinyb | cut -d / -f 3 | cut -d . -f 1`
    fi
    TB_BRANCH="${TB_CHAR}tb:${region}=>${branch_name}"
else
    TB_BRANCH=''
fi

echo $TB_BRANCH
}

When the function is available, you need to make the output visible on the prompt of your shell. The following example shows how to do this for zsh:

Include Tinybird information in the zsh prompt
echo 'export PROMPT="' $PS1 ' $(prompt_tb)"' >> ~/.zshrc

Restart your shell and go to the root of your project to see the Tinybird region and Workspace in your prompt.

Was this page helpful?
Updated