Agent API: AI-Powered Analytics Queries
Query your web analytics data using AI agents like Claude Code, Cursor, or Codex. Ask questions in plain English, get SQL that runs locally on your data.
Query your analytics with AI. Ask questions in plain English. Get answers from your own data.
The Agent API lets AI coding assistants, such as Claude Code, Cursor, or Codex, query your Fusionaly analytics with SQL. Your data never leaves your server. The AI generates SQL. Fusionaly runs it locally and returns the results.
Why AI + Self-Hosted Analytics
Section titled “Why AI + Self-Hosted Analytics”Most analytics tools hide their queries from you. You click through dashboards someone else designed. When you need to answer a custom question, you export CSVs and process the data by hand.
With Fusionaly’s Agent API:
- Ask in English: “What pages had the highest bounce rate last month?”
- AI writes the SQL: The agent generates a query against your schema
- Runs on your server: The query runs locally, so your data stays private
- Get direct answers: No dashboard hunting, no CSV exports
This works because Fusionaly uses SQLite. Your AI agent can query the single database file directly.
What You Can Ask
Section titled “What You Can Ask”Once configured, ask your AI assistant questions like:
Traffic questions:
- “What were my top 10 pages last week?”
- “How many unique visitors came from Google this month?”
- “Show me traffic by country for the past 30 days”
Conversion questions:
- “Which referrers drove the most signups?”
- “What’s my conversion rate from the pricing page?”
- “Compare this week’s goal completions to last week”
Trend questions:
- “Is my traffic growing or shrinking?”
- “What day of the week gets the most visits?”
- “Show me a month-over-month comparison”
Custom analysis:
- “Which blog posts have the best engagement (scroll depth > 75%)?”
- “What’s the average session duration by traffic source?”
- “Find pages where visitors leave without clicking anything”
1. Get Your API Key
Section titled “1. Get Your API Key”In your Fusionaly dashboard, go to Administration → Agents and create an API key.
2. Set Environment Variables
Section titled “2. Set Environment Variables”Add these to your shell profile (~/.zshrc or ~/.bashrc):
export FUSIONALY_HOST=https://your-fusionaly-instance.comexport FUSIONALY_API_KEY=your-api-key3. Install the Skill
Section titled “3. Install the Skill”Install the Fusionaly skill with the skills CLI:
npx skills add karloscodes/fusionaly-oss --skill fusionalyThis works with Claude Code, Cursor, Windsurf, Codex, and over 30 other AI agents.
4. Start Asking
Section titled “4. Start Asking”Open your AI assistant and ask a question about your analytics. The agent does the following:
- Connects to your Fusionaly instance
- Generates the right SQL
- Runs the query
- Presents the results in a readable format
How It Works
Section titled “How It Works”The Agent API exposes a SQL endpoint that accepts read-only queries. When you ask your AI assistant a question:
- You ask in English: “What’s my top traffic source?”
- AI generates SQL:
SELECT referrer, COUNT(*) as visits FROM events WHERE ... GROUP BY referrer ORDER BY visits DESC LIMIT 10 - Fusionaly executes: The query runs against your local SQLite database
- Results return: A JSON response with the data
- AI formats the answer: “Your top traffic source is Google, with 1,234 visits this month”
The AI never sees your raw data. It sees only the query results for your question.
Privacy & Security
Section titled “Privacy & Security”- Data stays local: Queries run on your server, not in the cloud
- Read-only access: The API allows only SELECT queries
- API key required: Every request must include your secret key
- No data training: Fusionaly never uses your analytics data to train AI models
This is the advantage of combining self-hosted analytics with local AI tools: you control your data and your queries.
Supported AI Tools
Section titled “Supported AI Tools”Any AI coding assistant that can make HTTP requests works with the Agent API:
- Claude Code (Anthropic’s CLI)
- Cursor (AI code editor)
- Codex (OpenAI’s CLI)
- Windsurf (Codeium’s editor)
- Continue (open source)
- Aider (terminal-based)
- Custom agents via the REST API
Example Session
Section titled “Example Session”You: What were my top 5 pages yesterday?
Claude: I'll query your Fusionaly analytics.
Based on yesterday's data, your top 5 pages were:
| Page | Visitors | Avg Time ||-----------------------|----------|----------|| / | 342 | 45s || /docs/installation | 128 | 3m 12s || /pricing | 89 | 1m 45s || /why-fusionaly | 67 | 2m 30s || /docs/getting-started | 54 | 4m 15s |
The installation docs have high engagement (3+ minutes),suggesting visitors are actively setting up Fusionaly.Built in: Ask AI
Section titled “Built in: Ask AI”Fusionaly includes Ask AI. This is the same capability, built directly into the dashboard. Type your question and get an answer.
Ask AI is optional. It uses your own OpenRouter key. It never sends visitor data. Only your database schema and your questions go to OpenRouter.