# How to track API usage and monitor calls in real-time on Bubble.io: Step-by-Step

- Tool: Bubble
- Difficulty: Intermediate
- Time required: 20-25 min
- Compatibility: All Bubble plans
- Last updated: March 2026

## TL;DR

Tracking API usage in Bubble involves logging every API call with timestamp, status, and response time, building a real-time monitoring dashboard with call volume charts, setting up alerts for failures and rate limit warnings, and analyzing usage patterns to optimize costs. This tutorial covers the full API monitoring pipeline from logging through visualization to alerting.

## Overview: Tracking API Usage in Real-Time in Bubble

This tutorial shows you how to build an API monitoring system that logs every external API call, displays call volume and success rates on a dashboard, and alerts you when failures spike or rate limits approach.

## Before you start

- A Bubble app making external API calls
- Backend workflows for async logging
- A chart plugin installed for dashboard visualization
- Basic understanding of Bubble workflows and Data Types

## Step-by-step guide

### 1. Create the API log Data Types

Create an ApiLog Data Type with fields: api_name (text), endpoint (text), method (text), status_code (number), response_time_ms (number), is_success (yes/no), error_message (text), called_at (date), caller_user (User). Create a DailyApiMetric Data Type with fields: date (date), api_name (text), total_calls (number), success_count (number), failure_count (number), avg_response_time (number). The DailyApiMetric stores pre-aggregated data for fast dashboard loading.

**Expected result:** Your database supports detailed API call logging and pre-aggregated daily metrics.

### 2. Log API calls in your workflows

After every API Connector call in your workflows, add an async logging step using Schedule API Workflow. The backend workflow creates an ApiLog record with the call details. Record the timestamp before and after the API call to calculate response time. Check the API response for error indicators and set is_success accordingly. Using async logging ensures the main workflow is not slowed down by the logging process.

**Expected result:** Every API call is logged asynchronously without affecting user-facing workflow performance.

### 3. Build the monitoring dashboard

Create an admin 'api-monitoring' page. Add KPI cards showing: total calls today, success rate percentage, average response time, and failure count. Below, add a line chart showing call volume over time (using DailyApiMetric). Add a table showing recent failures (ApiLog where is_success = no, sorted by called_at descending). Add a dropdown filter for api_name to view metrics for specific integrations. Create a scheduled backend workflow that aggregates ApiLog records into DailyApiMetric records each night.

**Expected result:** An admin dashboard displays real-time API health metrics with charts and failure details.

### 4. Set up failure alerts

Create a scheduled backend workflow running every 5 minutes. It searches for ApiLog records from the last 5 minutes where is_success = no. If the failure count exceeds a threshold (e.g., 5 failures in 5 minutes), send an alert email to admins with the failure details. Also check for rate limit indicators: if any API returns a 429 status code, send an immediate alert. Store alert history in an Alert Data Type to prevent duplicate notifications.

> Pro tip: RapidDev can help build comprehensive API monitoring with Slack notifications, automatic retry logic, and cost tracking dashboards for your Bubble app.

**Expected result:** Admin team receives alerts when API failures spike or rate limits are approached.

## Complete code example

File: `Workflow summary`

```text
API MONITORING ARCHITECTURE
============================

DATA TYPES:
  ApiLog: api_name, endpoint, method, status_code,
          response_time_ms, is_success, error_message, called_at
  DailyApiMetric: date, api_name, total_calls,
                  success_count, failure_count, avg_response_time
  Alert: type, message, sent_at, resolved

LOGGING (async):
  After each API call → Schedule API Workflow:
    Create ApiLog with call details
    Calculate response_time = end - start timestamp

AGGREGATION (daily, scheduled midnight):
  Search ApiLog from yesterday
  Group by api_name
  Create DailyApiMetric per group:
    total_calls, success_count, failure_count, avg_response_time

DASHBOARD:
  KPI cards: Today's calls, success rate, avg response, failures
  Line chart: DailyApiMetric over time
  Failure table: Recent ApiLog where is_success = no
  Filter: api_name dropdown

ALERTS (every 5 min):
  Check: failures in last 5 min > threshold
  Check: any 429 status codes
  Action: Send email, create Alert record
```

## Common mistakes

- **Logging API calls synchronously in the main workflow** — Synchronous logging adds latency to every API call, slowing down user-facing features Fix: Use Schedule API Workflow to log asynchronously in a backend workflow
- **Querying raw ApiLog for dashboard metrics** — With thousands of daily API calls, aggregating raw logs on every dashboard load is extremely slow Fix: Pre-aggregate into DailyApiMetric records with a nightly scheduled workflow
- **Not archiving old API logs** — ApiLog records grow rapidly. Thousands of records per day consume storage and slow queries Fix: Archive or delete ApiLog records older than 30-90 days after daily aggregation

## Best practices

- Log API calls asynchronously to avoid impacting user experience
- Pre-aggregate daily metrics for fast dashboard loading
- Set up automated alerts for failure spikes and rate limits
- Archive raw logs after 30-90 days to manage storage
- Track response time trends to identify degrading API performance
- Filter dashboard by api_name to isolate issues with specific integrations

## Frequently asked questions

### How much storage do API logs consume?

Each ApiLog record is small (under 1KB), but at 1,000 calls per day, that is 365,000 records per year. Archive or delete old records after aggregation to manage storage.

### Can I monitor Bubble's internal workload unit usage?

Bubble provides workload metrics in Settings → Metrics. This tutorial covers monitoring external API calls specifically, which complements Bubble's built-in metrics.

### How do I calculate API success rate?

Success rate = (success_count / total_calls) * 100. Calculate from DailyApiMetric for fast access, or from ApiLog for real-time accuracy.

### Should I alert on every failure?

No. Occasional failures are normal. Alert on patterns: failure rate exceeding a threshold (e.g., 5 in 5 minutes) or specific error codes (429 rate limit, 500 server error).

### Can RapidDev help build API monitoring for my Bubble app?

Yes. RapidDev can implement comprehensive API monitoring with logging, dashboards, Slack alerts, cost tracking, and performance optimization recommendations.

---

Source: https://www.rapidevelopers.com/bubble-tutorial/track-api-usage-monitor-calls-realtime-bubble
© RapidDev — https://www.rapidevelopers.com/bubble-tutorial/track-api-usage-monitor-calls-realtime-bubble
