metabase-api-skill

psh-inc's avatarfrom psh-inc

Add, manage, and execute SQL scripts in self-hosted Metabase via REST API.Supports creating cards/questions, running queries, and managing collections.Use when: Creating Metabase dashboards programmatically, automating report generation,managing SQL questions/cards via API, or integrating Metabase with the casino platform.

0stars🔀0forks📁View on GitHub🕐Updated Jan 10, 2026

When & Why to Use This Skill

This Claude skill enables seamless programmatic interaction with self-hosted Metabase instances via REST API. It allows users to automate the entire business intelligence lifecycle—from executing complex SQL scripts and managing data collections to programmatically generating dynamic dashboards—bridging the gap between raw database queries and actionable visual insights.

Use Cases

  • Automated Dashboard Generation: Programmatically create and update Metabase dashboards to provide real-time visibility into business metrics like affiliate performance and player analytics.
  • Scalable SQL Card Management: Use the API to add, edit, or organize large volumes of SQL-based questions (cards) across various collections without manual UI interaction.
  • Ad-hoc Data Exploration: Execute on-demand SQL queries via REST API for rapid debugging, transaction reporting, and deep-dive data analysis.
  • Workflow Integration: Integrate Metabase reporting directly into external platforms or CI/CD pipelines to automate the delivery of scheduled reports and data-driven alerts.
namemetabase-api-skill
description|
Use whenCreating Metabase dashboards programmatically, automating report generation,
allowed-toolsRead, Edit, Write, Glob, Grep, Bash

Metabase API Skill

This skill covers programmatic interaction with Metabase's REST API for the casino platform. Use it for creating SQL-based cards (questions), managing collections, running ad-hoc queries, and automating dashboard creation. The casino platform uses Metabase for affiliate reporting (CellExpert metrics), player analytics, and transaction reporting.

Quick Start

Authentication

# Get session token
curl -X POST https://metabase.example.com/api/session \
  -H "Content-Type: application/json" \
  -d '{"username": "admin@casino.com", "password": "secret"}'

# Response: {"id": "session-token-here"}

Create a SQL Card

curl -X POST https://metabase.example.com/api/card \
  -H "Content-Type: application/json" \
  -H "X-Metabase-Session: ${SESSION_TOKEN}" \
  -d '{
    "name": "Player Deposits by Currency",
    "dataset_query": {
      "type": "native",
      "native": {
        "query": "SELECT currency, SUM(amount) as total FROM transactions WHERE type = '\''DEPOSIT'\'' GROUP BY currency",
        "template-tags": {}
      },
      "database": 1
    },
    "display": "bar",
    "visualization_settings": {},
    "collection_id": 5
  }'

Key Concepts

Concept Usage Example
Card A saved question/query SQL or GUI-based query
Collection Folder for organizing cards collection_id: 5
Database Connected data source PostgreSQL casino DB
Dashboard Container for multiple cards Player Overview
Template Tags Parameterized queries {{player_id}}

Common Patterns

Execute Ad-hoc Query

When: Running one-off queries for debugging or data exploration

curl -X POST https://metabase.example.com/api/dataset \
  -H "Content-Type: application/json" \
  -H "X-Metabase-Session: ${SESSION_TOKEN}" \
  -d '{
    "database": 1,
    "type": "native",
    "native": {
      "query": "SELECT * FROM players WHERE id = {{player_id}}",
      "template-tags": {
        "player_id": {"type": "number", "name": "player_id", "display-name": "Player ID"}
      }
    },
    "parameters": [{"type": "number", "target": ["variable", ["template-tag", "player_id"]], "value": 12345}]
  }'

List Collections

When: Finding where to place new cards

curl -X GET https://metabase.example.com/api/collection \
  -H "X-Metabase-Session: ${SESSION_TOKEN}"

See Also

  • patterns - Card creation, query optimization, error handling
  • workflows - Dashboard automation, report scheduling

Related Skills

  • See the postgresql skill for SQL query optimization and schema design
  • See the spring-boot skill for backend API integration with Metabase