Puffn Documentation
Welcome to the Puffn API documentation. Learn how to track events and query your analytics data.
Coming Soon
Puffn is currently in development. Join our waitlist to get early access when we launch.
Overview
Puffn provides a simple REST API for tracking events and querying analytics data. Our API is built with performance in mind, using Rust and ClickHouse to deliver blazing fast analytics for your applications.
Simple REST API
Easy-to-use REST API for sending events and querying data based on timeframes.
Bring Your Own Charts
Use your favorite charting library with our data. Works with Recharts, Chart.js, and more.
Blazing Fast
Built with Rust and ClickHouse for incredible performance, even with billions of events.
Authentication
All API requests require authentication using an API key. You'll need to include your API key in theX-API-Keyheader with every request.
Installation
Puffn doesn't require any client-side SDK. You can use the REST API directly with any HTTP client. However, we provide some helper libraries for popular frameworks.
npm install @puffn/react
API Reference
Events API
The Events API allows you to track events in your application. Events can be anything from page views to button clicks to custom actions.
/eventsRequest Body
Response
Query API
The Query API allows you to retrieve analytics data based on events, metrics, and timeframes.
/queryRequest Body
Response
Metrics
Metrics define what type of calculation to perform on your event data. Here are the available metrics:
| Metric | Description |
|---|---|
| count | Count of events |
| unique | Count of unique values for a property (requires property parameter) |
| sum | Sum of values for a property (requires property parameter) |
| avg | Average of values for a property (requires property parameter) |
| min/max | Minimum or maximum value for a property (requires property parameter) |
Timeframes
Timeframes define the period for which you want to retrieve data. You can specify a custom timeframe with start and end dates, or use one of the predefined timeframes:
| Timeframe | Description |
|---|---|
| today | Data for the current day |
| yesterday | Data for the previous day |
| this_week | Data for the current week |
| last_week | Data for the previous week |
| this_month | Data for the current month |
| last_month | Data for the previous month |
Examples
React + Recharts Example
Here's an example of how to use Puffn with React and Recharts to create a simple analytics dashboard.
Node.js Example
Here's an example of how to use Puffn with Node.js to track server-side events.
Secure API Route Example
Here's an example of how to create a secure API route in Next.js to proxy requests to Puffn while keeping your API key secure on the server.