Skip to main content

Tinybird TypeScript SDK

A TypeScript-first SDK for defining Tinybird datasources, pipes, and queries with full type inference and CLI tooling.

Get Started →

Key Features

Type-Safe Schemas

Define datasources and pipes in TypeScript with full type inference for schemas, parameters, and outputs.

CLI Tooling

Built-in CLI with dev mode, build, deploy commands, and branch-based development workflow.

Runtime Client

Type-safe client for querying endpoints and ingesting data with automatic parameter validation.

External Connections

First-class support for Kafka, S3, and GCS connections with materialized views and sink pipes.

Quick Example

import { defineDatasource, defineEndpoint, t, p, engine, node } from "@tinybirdco/sdk";

// Define a datasource
export const pageViews = defineDatasource("page_views", {
  schema: {
    timestamp: t.dateTime(),
    pathname: t.string(),
    session_id: t.string(),
    country: t.string().lowCardinality().nullable(),
  },
  engine: engine.mergeTree({
    sortingKey: ["pathname", "timestamp"],
  }),
});

// Define an endpoint
export const topPages = defineEndpoint("top_pages", {
  params: {
    start_date: p.dateTime(),
    end_date: p.dateTime(),
    limit: p.int32().optional(10),
  },
  nodes: [
    node({
      name: "aggregated",
      sql: `
        SELECT pathname, count() AS views
        FROM page_views
        WHERE timestamp >= {{DateTime(start_date)}}
          AND timestamp <= {{DateTime(end_date)}}
        GROUP BY pathname
        ORDER BY views DESC
        LIMIT {{Int32(limit, 10)}}
      `,
    }),
  ],
  output: {
    pathname: t.string(),
    views: t.uint64(),
  },
});

Get Started

Installation

Install the SDK and set up your project

Quickstart

Build your first type-safe Tinybird project

API Reference

Explore the complete API documentation

Learn More

Core Concepts

Understand datasources, pipes, and type inference

CLI Commands

Master the CLI for development and deployment

Guides

Step-by-step guides for common workflows

Configuration

Configure your project and environment

Build docs developers (and LLMs) love