Quick start for Tinybird CLI¶
With Tinybird, you can ingest data from anywhere, query and transform it using SQL, and publish your data as high-concurrency, low-latency REST APIs.
Once you've familiarized yourself with Tinybird, you're ready to start automating and scripting the management of your Workspace using the Tinybird command-line interface (CLI). The CLI also forms the basis for all your CI/CD workflows so, if you're looking to set up CI/CD, you'll want to get comfortable with this before you dive into our CI/CD documentation.
By the end of this Quick Start, you will download and configure the Tinybird CLI, create a Workspace, ingest data, create a query, publish an API, and confirm your setup works properly.
Step 1: Create your Tinybird account¶
First, you will need to create a Tinybird account. It's free to get started, and no credit card is required. (Read more about Tinybird pricing plans)
Sign up for TinybirdStep 2: Download and install the Tinybird CLI¶
Follow the instructions to set up the Tinybird command-line interface (CLI).
Be sure to complete the setup and authenticate with your Tinybird account in the cloud and region you prefer.
Step 3: Create your Workspace¶
A Workspace is an area that contains a set of Tinybird resources, including Data Sources, Pipes, Nodes, API Endpoints, and Tokens.
Create a Workspace named customer_rewards
(note: you will need to supply a unique name.)
tb workspace create customer_rewards
Step 4: Ingest data¶
For this Quick Start, we will use data for a fictitious online coffee shop.
Download data fileIngest the data you just downloaded into Tinybird. In the first command below, Tinybird will infer the schema from the datafile and generate a .datasource
file. In the second comamnd below, you will push the .datasource
file to Tinybird, which will generate the Data Source. And in the third command below, Tinybird will ingest the data.
tb datasource generate orders.ndjson tb push orders.datasource tb datasource append orders orders.ndjson
Step 5: Query data using a Pipe and Publish it as an API¶
In Tinybird, you can create Pipes to query your data using SQL.
Here's a Pipe with a SQL instruction that returns the number of records Tinybird has ingested from the data file.
tb pipe generate rewards 'select count() from orders' tb push rewards.pipe
When you push your Pipe, it is published automatically as a high-concurrency, low-latency REST API endpoint.
Step 6: Call your API¶
You can test your API endpoint using a cURL command.
First, create and obtain the read token for the API endpoint.
tb token create static rewards_read_token --scope PIPES:READ --resource rewards tb token copy rewards_read_token
Copy the read token and insert it into a cURL command.
curl --compressed -H 'Authorization: Bearer your_read_token_here' https://api.us-east.aws.tinybird.co/v0/pipes/rewards.json
🎉 Celebrate and next steps 🎉¶
Congrats! You have finished creating your first API Endpoint in Tinybird!
What should you try next?
- Check out our Tutorials
- Learn more about User-Facing Analytics in our Use Case Hub
- Learn about Tinybird Charts and build beautiful visualizations for your API endpoints