A REST API bridge for Foundry Virtual Tabletop β enabling external tools, automations, and integrations to interact with your Foundry VTT worlds.
Foundry VTT is a self-hosted virtual tabletop platform, but it lacks a native API for external integrations. This project fills that gap by providing a WebSocket relay server that exposes your Foundry world data through a clean REST API.
Use cases:
- Build custom dashboards or companion apps for your game
- Automate game master tasks (e.g., trigger macros, roll dice remotely)
- Integrate with MIDI controllers, stream decks, or voice assistants
- Create Discord bots that interact with your world data
- Run automated integration tests
- Develop tools that read/write actors, items, scenes, and more
βββββββββββββββββββ WebSocket βββββββββββββββββββ REST API βββββββββββββββββββ
β Foundry VTT β ββββββββββββββββββββΊ β Relay Server β ββββββββββββββββββΊ β Your App/Tool β
β + Module β β (this repo) β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Foundry Module connects to the relay server via WebSocket
- Relay Server exposes REST endpoints and routes requests to your Foundry world
- Your application calls the REST API to search, read, create, and modify entities
| Component | Description |
|---|---|
| Relay Server (this repo) | Node.js/Express server with WebSocket relay and REST API |
| Foundry Module | Foundry VTT module that connects your world to the relay |
You can either use the public relay server (no setup required) or self-host your own instance.
- Go to https://foundryrestapi.com
- Create an account and copy your API key from the dashboard
- Install the Foundry module and set the relay URL to
wss://foundryrestapi.com
The public relay has rate limits (100 requests/month free, 1000/day). For unlimited usage, self-host or subscribe for $5/month.
# Download and run with Docker Compose
curl -O https://raw.githubusercontent.com/ThreeHats/foundryvtt-rest-api-relay/main/docker-compose.local.yml
docker compose -f docker-compose.local.yml up -dThe server runs at http://localhost:3010.
- Open your relay server (
http://localhost:3010or the public URL) in your browser - Create an account using the Sign Up form
- After logging in, your API key is displayed on the dashboard β click Copy to copy it
Install via manifest URL in Foundry VTT:
https://github.com/ThreeHats/foundryvtt-rest-api/releases/latest/download/module.json
Enable the module in your world and configure the relay URL in the module settings:
- Public relay:
wss://foundryrestapi.com - Self-hosted:
ws://localhost:3010(orwss://if using HTTPS)
curl -X GET "http://localhost:3010/clients" \
-H "x-api-key: YOUR_API_KEY"You'll see your connected Foundry worlds listed in the response.
The REST API provides endpoints across these resource groups:
| Endpoint Group | Description |
|---|---|
/clients |
List connected Foundry worlds |
/get, /create, /update, /delete |
CRUD operations for entities (actors, items, scenes, etc.) |
/search |
Search your Foundry database |
/roll |
Perform dice rolls |
/macro |
Execute macros remotely |
/encounter |
Combat encounter management |
/dnd5e |
D&D 5th Edition specific operations |
/structure |
World structure information |
/session |
Headless Foundry sessions via Puppeteer |
and more |
Read the api reference for more details |
Authentication: Include your API key in the x-api-key header for all requests.
The Postman Collection is deprecated β the interactive API documentation now includes interactive tests and code examples in multiple languages.
services:
relay:
# For production, pin to a specific version (e.g., 2.1.0) instead of 'latest'
image: threehats/foundryvtt-rest-api-relay:latest
container_name: foundryvtt-rest-api-relay
ports:
- "3010:3010"
environment:
- APP_ENV=production
- PORT=3010
- DB_TYPE=sqlite
volumes:
- ./data:/app/data
command: pnpm local:sqlite
restart: unless-stoppeddocker-compose up -dπ‘ Tip: For production stability, pin to a specific release tag (e.g.,
threehats/foundryvtt-rest-api-relay:2.1.0) instead oflatest.
Prerequisites: Node.js v18+ (v20 recommended), pnpm
git clone https://github.com/ThreeHats/foundryvtt-rest-api-relay.git
cd foundryvtt-rest-api-relay
pnpm install
# Build SQLite native module (path may vary with sqlite3 version)
cd node_modules/.pnpm/sqlite3@*/node_modules/sqlite3 && npm run install && cd -
# Run with SQLite (recommended for local development)
pnpm run local:sqliteNote: On Windows, the SQLite build step may require additional configuration. See the full installation guide for platform-specific instructions.
Key environment variables (see full configuration guide for details):
| Variable | Default | Description |
|---|---|---|
PORT |
3010 |
Server port |
DB_TYPE |
sqlite |
Database type (sqlite, postgres, memory) |
DATABASE_URL |
β | PostgreSQL connection string (required for postgres DB_TYPE) |
WEBSOCKET_PING_INTERVAL_MS |
20000 |
WebSocket ping interval for keep-alive |
CLIENT_CLEANUP_INTERVAL_MS |
15000 |
Interval for removing inactive clients |
REDIS_URL |
β | Redis URL for session storage in multi-instance deployments |
MONTHLY_REQUEST_LIMIT |
0 (unlimited) |
Monthly API request limit per free-tier user. 0 = unlimited. Paid subscribers are always unlimited |
PER_MINUTE_REQUEST_LIMIT |
300 |
Per-API-key request limit per minute (0 to disable) |
SMTP_HOST |
β | SMTP server hostname (enables email delivery) |
SMTP_PORT |
587 |
SMTP server port |
SMTP_USER |
β | SMTP auth username |
SMTP_PASS |
β | SMTP auth password |
SMTP_FROM |
noreply@foundryvtt-relay.com |
From address for outgoing emails |
SMTP_SECURE |
false |
Use TLS for SMTP connection |
FRONTEND_URL |
http://localhost:3010 |
Base URL for links in emails and Stripe redirects |
Self-hosting tip: Request limits default to
0(unlimited) in the Docker image β no configuration needed. SetPER_MINUTE_REQUEST_LIMIT=0to also disable the per-minute burst limit. Subscription UI (plan badge, upgrade button) is automatically hidden whenSTRIPE_SECRET_KEYis not set.
Users can reset their password via the "Forgot your password?" link on the login page. The flow:
- User submits their email address
- If SMTP is configured, a reset link is sent via email. Without SMTP configuration, the reset URL is logged to the server console β useful for self-hosted instances.
- The reset link is valid for 1 hour and can only be used once.
Password requirements (enforced on both registration and reset):
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
Relay Server:
- Runtime: Node.js + TypeScript
- Framework: Express.js
- Real-time: WebSocket (ws)
- Database: SQLite (default), PostgreSQL + Redis (production), or in-memory
- Headless Browser: Puppeteer (for unattended Foundry sessions)
- Docs: Docusaurus + TypeDoc (auto-generated API reference)
- Testing: Jest + TypeDoc (partially auto-generated tests)
Foundry Module:
- TypeScript module for Foundry VTT
- Integrates with QuickInsert for search capabilities
pnpm docs:install # Install doc dependencies
pnpm docs:generate # Generate API docs from TypeScript comments
pnpm test:generate # Generate bare bones Jest tests
pnpm test # Run full integration tests while capturing examples
pnpm docs:examples # Update API docs with test examples
pnpm docs:dev # Start docs server at localhost:3000- π Documentation
- π€ Contributing Guide
- π¬ Discord Community
MIT Β© ThreeHats