Deploy Metabase API
REST API for questions and automation
metabase/metabase
Just deployed
Just deployed
/var/lib/postgresql/data
Deploy and Host self hosted Metabase API (Headless BI) on Railway
The Metabase REST API turns dashboards into a query engine for scripts, bots, or products. Self-hosting on Railway keeps it on your infrastructure with no per-request or seat fees. This guide covers the container, companion Postgres, and env vars that keep API keys and encrypted settings stable.
About Hosting Metabase API open-source software on Railway (self hosted Metabase template)
Metabase is usually a UI tool, but the API is where headless work happens: pull saved question results into Python, trigger refreshes from webhooks, or provision collections programmatically. Cloud BI vendors charge per seat or API call; self-hosted Metabase on Railway gives the same REST endpoints against a container you control.
The Railway template pairs Metabase and Postgres containers. Metabase stores metadata - saved questions, dashboards, API keys, users - in that Postgres. Analytics databases you query are separate, connected after first boot via admin.
Why Deploy Metabase API, the Tableau alternative on Railway (Railway Free Trial)
Tableau's REST API is bolted onto a licensed product. Metabase's API is first-class in OSS: generate a key, scope permissions, start querying. No per-seat or per-call fees. For headless BI, that matters more than chart polish. Self-hosting on Railway keeps data in your infra - a hard requirement for compliance or multi-tenant backends.
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Metabase API on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Railway vs Other Hosting Providers and VPS for Metabase API self hosting
Railway couples Metabase and Postgres with networking, HTTPS, and editable env vars. A raw VPS means Docker Compose, TLS, firewall, and reverse proxy before login. DigitalOcean and Hetzner cost less at scale if you self-manage; AWS adds control but overhead for two containers.
| Provider | Setup complexity | Cost for small stack | Best fit |
|---|---|---|---|
| Railway | Low (template + env vars) | ~$5-15/mo | Small teams, quick deployments |
| DigitalOcean | Medium (Droplet + Docker) | ~$12-24/mo | Comfortable with Linux admin |
| AWS | High (VPC, RDS, ECS) | $30+/mo | Enterprise compliance needs |
| Hetzner | Medium (Cloud + Docker) | ~$6-12/mo | Budget-conscious self-managers |
Common Use Cases for hosted Metabase API
A cron hits POST /api/card/:id/query nightly, pulls yesterday's revenue, writes to Slack or Sheets. No one opens the UI; the saved question is the SQL, the API is delivery. Another pattern: tenant provisioning for B2B SaaS - script user, collection, and permission creation per customer.
Dependencies for Metabase API Docker hosted on Railway
The official image bundles JVM and drivers, but the default H2 app DB gets wiped on every redeploy. You need external Postgres for production - saved questions and API keys vanish otherwise. Point Metabase only at its own Postgres; analytics connections happen later. Avoid the H2 trap with the right env vars.
Deployment Dependencies for Managed Metabase API Service (Business Intelligence)
Use a Railway template with Metabase and Postgres (ghcr.io/railwayapp-templates/postgres-ssl, PG 17). Set MB_DB_TYPE=postgres, MB_DB_HOST, MB_DB_PORT, MB_DB_USER, MB_DB_PASS, MB_DB_DBNAME to the companion service.
Implementation Details for Metabase API (Using Metabase official docker image)
Use metabase/metabase, pin v0.63.x, not latest. App listens on 3000; health check GET /api/health. First boot runs migrations against Postgres then shows the setup wizard. Generate an API key under Admin then Settings then Authentication, or use POST /api/session for short-lived tokens. Keys don't expire; scope them per permission.
How does Metabase API compare against other Business Intelligence platforms
Every BI has an API, but philosophies differ. Metabase's is pragmatic JSON mirroring the UI. Tableau's is capable but licensed. Power BI's assumes Azure. Looker's is really LookML. Superset's is less mature for headless work.
Metabase API vs Tableau (Tableau Alternative)
Tableau's REST API covers publishing and user management but requires Tableau Server/Cloud with per-user fees. Metabase covers core headless flows free. Tableau wins on enterprise governance, data source certifications, and viz complexity; for programmatic saved SQL, Metabase is better.
Metabase API vs Power BI (Power BI Alternative)
Power BI's API is extensive but Azure-native, requiring Azure AD and app registrations. Metabase runs anywhere Postgres runs. Non-Azure teams find Metabase simpler. Microsoft 365 shops get Power BI effectively free, but that assumes you're all-in on Azure AD and the Microsoft graph.
Metabase API vs Looker (Looker Alternative)
Looker's modeling happens in LookML before any API call - governed results at enterprise, sales-quoted pricing. Metabase gives direct saved SQL without a modeling layer, faster but less consistent with many ad-hoc analysts. Looker's modeling layer also provides row-level security in the cloud version; Metabase OSS lacks that.
Metabase API vs Apache Superset (Superset Alternative)
Superset is the closest OSS rival, but its API is less polished; energy went to the React UI and SQL Lab. Metabase's API is more mature for headless workflows: first-class keys, stable endpoints, better docs. Superset wins for exploration depth and chart types, but API users will fight an unstable surface.
How to use Metabase API (the OSS Business Intelligence)?
REST + JSON, curl-friendly. Generate an API key, send X-API-Key. Test with curl -H "X-API-Key: YOUR_KEY" http://localhost:3000/api/health. Key endpoints: POST /api/card/:card-id/query, GET /api/dashboard/:id, POST /api/collection. Permissions are collection-based, not table-level. Errors are JSON with clear messages.
How to self host Metabase API on other VPS Services (Metabase API self hosting guide)
The same container runs anywhere Docker runs. You manage Postgres, TLS, and process supervision manually. Below is the generic path.
Clone the Repository
No need to clone for deployment - use the official Docker image. Source is at github.com/metabase/metabase if you want to inspect. Create a docker-compose.yml pulling Metabase and Postgres; Railway's template automates this.
Install Dependencies
On Ubuntu VPS, install Docker and Docker Compose. Metabase bundles JVM and drivers - no separate Java/Clojure. BigQuery/Snowflake drivers included.
Configure Environment Variables
Same env vars as Railway: MB_DB_TYPE, MB_DB_HOST, MB_DB_PORT, MB_DB_USER, MB_DB_PASS, MB_DB_DBNAME, plus MB_ENCRYPTION_SECRET_KEY and MB_SITE_URL. Handle TLS via Caddy or Nginx; set MB_SITE_URL to HTTPS.
Start the Metabase API Application
Run docker-compose up -d, then docker compose logs -f metabase to watch migrations. First boot takes a minute. Open browser, create admin, generate API key. API usage identical to Railway.
Official Pricing of Metabase API (Metabase API pricing)
Metabase OSS is free under AGPL, including full REST API and unlimited users. AGPL requires releasing modifications if offered as a service - rarely an issue internally. Cloud Starter ~$85/mo plus per-user; Pro much higher with SSO, RLS, interactive embed. API is same; you pay for hosting and extras.
Metabase API cloud vs self hosted comparison (Pricing, features, costs, and more)
Who gets paged at 3 a.m.? Cloud means someone else; self-host means you. For internal automation, Railway is cheaper than Cloud Starter. For customer-facing dashboards with uptime SLAs, Cloud's support may justify premium. Headless features are identical.
Monthly cost of self hosting Metabase API on Railway
Small Metabase + Postgres on Railway Hobby runs about $5-15/mo - no per-user or per-call fees. Scale vertically first; extra instances can share the same Postgres app DB when you need them.
System Requirements for Hosting Metabase API on a VPS
Metabase is JVM-based, wants RAM. 2GB comfortable for a handful of concurrent API requests; 4GB for larger dashboards. Disk minimal; Postgres grows slowly. API returns results, doesn't warehouse them.
Frequently Asked Questions (FAQs)
Can I use Metabase's API without ever opening the UI?
No, boot, create admin via wizard, generate key first. Then automation works via HTTP; no UI login needed unless changing global settings.
Do Metabase API keys expire?
API keys don't expire. Treat like passwords: store in secrets manager, scope tightly, rotate on staff changes. Session tokens from POST /api/session expire; use keys for persistent scripts.
Can I run multiple Metabase instances against the same Postgres database?
Technically yes but unsupported in OSS. Two instances both run migrations and can corrupt state. One instance per Postgres DB unless paid Pro/Enterprise.
What happens if I redeploy and my MB_ENCRYPTION_SECRET_KEY changes?
Encrypted settings become unreadable, causing decryption errors. Restore old key; if lost, re-enter credentials in admin. Keep stable Railway env var.
Is the Metabase API rate-limited?
No built-in limits in OSS. Limits are your RAM, CPU, DB connections. Add throttling/queuing/caching for busy webhooks or customer-facing endpoints.
Can I embed Metabase dashboards in my app using the API?
API returns data, but interactive embedding requires Pro. OSS supports public links, static signed embeds, or your own frontend on API JSON. For headless use, API is cleaner than iframe.
Template Content
metabase/metabase
metabase/metabase