How It Works
flAPI simplifies the process of creating data APIs into three straightforward steps. This effectively decouples high-throughput API consumers (like AI agents or web services) from traditional backend data systems, resulting in significantly improved performance and lower costs.
The Three-Step Processβ
1. Connect Your Dataβ
Point flAPI to your data sourcesβwhether they're cloud data warehouses like BigQuery and Snowflake, traditional databases like PostgreSQL, or file formats like Parquet and CSV.
# Example: Connect to multiple data sources
connections:
bigquery-warehouse:
init: |
INSTALL 'bigquery';
LOAD 'bigquery';
properties:
project_id: 'my-project'
customers-parquet:
properties:
path: './data/customers.parquet'
What happens: flAPI leverages DuckDB's powerful extension ecosystem to connect to 20+ data sources out of the box. You can mix and match sources in a single API.
2. Define APIs with SQLβ
Write standard SQL queries and define your endpoints using simple YAML files. Use Mustache syntax to create dynamic, parameterized queries.
Endpoint Configuration (sqls/customers.yaml
):
url-path: /customers/
request:
- field-name: segment
field-in: query
description: Filter by market segment
required: false
template-source: customers.sql
connection:
- customers-parquet
SQL Template (sqls/customers.sql
):
SELECT
c_custkey as id,
c_name as name,
c_acctbal as balance
FROM '{{{conn.path}}}'
WHERE 1=1
{{#params.segment}}
AND c_mktsegment LIKE '%{{{params.segment}}}%'
{{/params.segment}}
What happens: flAPI automatically handles parameter validation, SQL injection prevention, and generates OpenAPI documentation.
3. Access Instantlyβ
Run the flAPI server and immediately access your data through secure, documented REST APIsβplus MCP tools for AI agents.
# Start flAPI
$ ./flapi -c config.yaml
β Loaded 12 endpoints
β Server listening on :8080
β‘ Ready in 1.2ms
# Call your API
$ curl http://localhost:8080/customers?segment=AUTO
{
"data": [
{"id": 1, "name": "Customer ABC", "balance": 7500.25},
{"id": 2, "name": "Customer XYZ", "balance": 12300.50}
]
}
What happens: Your data is now accessible via a production-ready REST API with authentication, rate limiting, and automatic documentation.
The Architectureβ
Why This Mattersβ
Problem: Direct Warehouse Accessβ
User Request β BigQuery β Wait 2-10s β $0.05 cost
(Every single request hits the warehouse)
10,000 requests/day = $500/day = $15,000/month
Solution: flAPI Serving Layerβ
User Request β flAPI Cache β Response in 1-50ms β Free
(Warehouse queried once per hour)
Background: flAPI β BigQuery β Refresh cache ($0.05)
Total cost: ~$1.20/day = $36/month
Savings: 99.76%
Speed: 1000-20,000x faster
Key Benefitsβ
- π Performance: Sub-millisecond responses instead of seconds
- π° Cost Reduction: 90%+ savings on warehouse costs
- π Security: Built-in authentication, rate limiting, row-level security
- π€ AI-Ready: Automatic MCP tool generation for AI agents
- π¦ Simple: Single binary, zero dependencies, local-first development
Next Stepsβ
- Architecture Deep Dive: Understand the technical details and performance characteristics
- Caching Strategy: Learn how caching saves costs and improves performance
- SQL Templating: Master dynamic SQL queries with Mustache
- Quickstart Guide: Build your first API in 5 minutes
- Endpoints Overview: Configure REST API endpoints
- Examples: See real-world implementations