REST API
Base URL: https://mongoplayground.com/api/v1. OpenAPI 3.1: https://mongoplayground.com/api/v1/openapi.json. Quick start for agents: https://mongoplayground.com/llms.txt. No account or key is needed.
Endpoints
Method · Path · What it does
POST · /run · Run a script against documents you supply and return a transcript
POST · /explain · Return query plans instead of running the statements
POST · /validate · Check a request without running it (no database)
POST · /share · Save a playground; returns a UUID link
GET · /p/{id} · Load a shared playground
POST · /export · Export as a mongosh script or JSON
GET · /examples · Ready-to-run templates and examples (each is a valid /run body)
GET · /limits · Hard limits and capabilities
GET · /guide · How to run it yourself, with commands
Run a script
curl -s -X POST https://mongoplayground.com/api/v1/run -H 'content-type: application/json' -d '{
"script": "db.collection.find({ age: { $gt: 40 } })",
"config": "[{ name: \"Ada\", age: 36 }, { name: \"Linus\", age: 55 }]"
}'
script holds one or more mongosh-style statements, run in order. config is the Data panel text: an array (one collection named collection), db = { name: [...] }, or db = { name: { documents, indexes, searchIndexes, vectorSearchIndexes } }. A failing statement stops the script and the response keeps the earlier output (ok: false).
Errors and limits
Errors are {code, message, hint} with stable codes; follow the hint. Work endpoints are rate limited per client: 429 with Retry-After and X-RateLimit-* headers. Limits: 8 collections, 256 documents each, 32 MB per request, 10 s per statement, 3 indexes plus 1 Atlas Search and 1 Vector Search index per collection. Requests and responses may be gzip, br, zstd or deflate compressed.
Agents
Use the MCP server for tool calling, or this API directly.