DEV Community

Alex Spinov
Alex Spinov

Posted on

Tinybird Has a Free API — Here's How to Build Real-Time Analytics Endpoints in Minutes

A data engineer told me: 'We had a ClickHouse cluster, a Python API, and a React dashboard. Three systems to maintain for one analytics feature.' He replaced all three with Tinybird — ingest data, write SQL, get an API endpoint. Done.

What Tinybird Offers for Free

Tinybird free tier:

  • 100 GB data processed/day
  • 10 GB storage
  • 1,000 API requests/day
  • Unlimited data sources
  • Real-time ingestion (millions of rows/second)
  • SQL-based transformation
  • Instant API endpoints from SQL queries
  • Built on ClickHouse

Quick Start

# Install CLI
pip install tinybird-cli

# Login
tb auth --token YOUR_TOKEN

# Create a data source
tb push datasource events.datasource
Enter fullscreen mode Exit fullscreen mode

Ingest Data

# REST API — ingest JSON
curl -X POST 'https://api.tinybird.co/v0/events?name=page_views' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"timestamp":"2026-03-29T10:00:00","page":"/home","user_id":"123","country":"US","device":"mobile"}'

# Bulk ingest (NDJSON)
curl -X POST 'https://api.tinybird.co/v0/events?name=page_views' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"timestamp":"2026-03-29T10:01:00","page":"/pricing","user_id":"456","country":"DE","device":"desktop"}
{"timestamp":"2026-03-29T10:02:00","page":"/signup","user_id":"123","country":"US","device":"mobile"}'
Enter fullscreen mode Exit fullscreen mode

Create API Endpoint from SQL

-- pipes/top_pages.pipe
-- This SQL becomes an API endpoint automatically!

%
SELECT 
    page,
    uniq(user_id) AS unique_visitors,
    count() AS page_views,
    round(avg(session_duration), 1) AS avg_duration
FROM page_views
WHERE timestamp >= now() - interval {{period:String('7 day')}}
GROUP BY page
ORDER BY page_views DESC
LIMIT {{limit:UInt16(10)}}
Enter fullscreen mode Exit fullscreen mode
# Push the pipe
tb push pipes/top_pages.pipe

# Now it's a live API!
curl 'https://api.tinybird.co/v0/pipes/top_pages.json?token=YOUR_READ_TOKEN&period=30%20day&limit=5'
Enter fullscreen mode Exit fullscreen mode

Node.js Integration

const TINYBIRD_TOKEN = process.env.TINYBIRD_TOKEN;

// Ingest events
async function trackEvent(event) {
  await fetch('https://api.tinybird.co/v0/events?name=page_views', {
    method: 'POST',
    headers: { 'Authorization': `Bearer ${TINYBIRD_TOKEN}` },
    body: JSON.stringify({
      ...event,
      timestamp: new Date().toISOString()
    })
  });
}

// Query API endpoint
async function getTopPages(period = '7 day', limit = 10) {
  const res = await fetch(
    `https://api.tinybird.co/v0/pipes/top_pages.json?period=${encodeURIComponent(period)}&limit=${limit}`,
    { headers: { 'Authorization': `Bearer ${TINYBIRD_TOKEN}` } }
  );
  const { data } = await res.json();
  return data;
}

// Use in your app
app.get('/api/analytics/top-pages', async (req, res) => {
  const data = await getTopPages(req.query.period, req.query.limit);
  res.json(data);
});
Enter fullscreen mode Exit fullscreen mode

Real-Time Dashboard

-- pipes/live_dashboard.pipe
-- Real-time metrics updating every second

%
SELECT
    toStartOfMinute(timestamp) AS minute,
    count() AS events,
    uniq(user_id) AS active_users,
    countIf(event = 'purchase') AS purchases,
    sumIf(amount, event = 'purchase') AS revenue
FROM events
WHERE timestamp >= now() - interval 1 hour
GROUP BY minute
ORDER BY minute DESC
Enter fullscreen mode Exit fullscreen mode

Use Cases

  • Product analytics — real-time user behavior dashboards
  • API analytics — request counts, latency percentiles
  • E-commerce — live sales, inventory, conversion funnels
  • IoT — sensor data aggregation and alerting
  • Ad tech — impression/click tracking at scale

Need to collect analytics data from websites? Check out my web scraping actors on Apify — automated data collection.

Need real-time analytics? Email me at spinov001@gmail.com.

Top comments (0)