api.sqlize.online API

v1

api.sqlize.online is an online PHP & SQL execution sandbox. The REST API lets you save code snippets, run them against 30+ database engines, execute PHP across multiple runtime versions with an optional live database, and generate ER diagrams.

This API powers sqlize.online, phpize.online, and sqltest.online. To integrate it into another service, contact rozhnev@msn.com.

Base URL: https://api.sqlize.online/api  ·  All request bodies must be Content-Type: application/json  ·  All responses are JSON

MCP server

AI assistants (Claude, Cursor, VS Code Copilot and other Model Context Protocol clients) can run SQL here directly: on real engines, in fresh databases, with every result linked back to sqlize.online. No account or API key needed.

MCP https://api.sqlize.online/mcp Streamable HTTP, stateless JSON

Connect

# Claude Code
claude mcp add --transport http sqlize https://api.sqlize.online/mcp

# claude.ai: Settings → Connectors → Add custom connector → URL above

# Cursor (~/.cursor/mcp.json), Windsurf, other clients
{ "mcpServers": { "sqlize": { "url": "https://api.sqlize.online/mcp" } } }

# VS Code (.vscode/mcp.json)
{ "servers": { "sqlize": { "type": "http", "url": "https://api.sqlize.online/mcp" } } }

Tools

ToolArgumentsWhat it does
list_databases—Engines and versions with the sql_version id to pass to other tools; marks the preloaded sample databases
run_sqlsql_version, code, calculate_cost?Runs a script in a fresh database that is dropped afterwards; returns every result set as a table, errors per statement, and a sqlize.online link
describe_databasesql_versionTables, columns and foreign keys of a preloaded sample database (Sakila, AdventureWorks, HR, …)
create_share_linksql_version, codeSaves a script without running it and returns its sqlize.online link

Example

POST /mcp
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": { "name": "run_sql",
              "arguments": { "sql_version": "psql18", "code": "SELECT 1 AS one;" } } }

Limits

ResultUp to 200 rows per result set, 30 KB per answer, 200 characters per cell; the rest is cut and marked
ScriptUp to 100 KB of SQL per call
Rate100 requests per 10 seconds per IP; when the server is busy a call returns an error asking to retry
DataNothing persists between calls; the sample databases are read-only
Protocol versions 2025-11-25, 2025-06-18 and 2025-03-26. Only POST is supported: no SSE stream and no session id.

Parameters

Meta

GET /api/versions List all supported PHP & SQL versions

Response

{
  "php_versions": { "php81": "PHP 8.1", "php82": "PHP 8.2", … },
  "sql_versions": { "mysql80": "MySQL 8.0", "psql17": "PostgreSQL 17 + PostGIS", … },
  "erd_support":  ["mysql80", "psql14", …],
  "preloaded":    ["mysql80_sakila", "psql10demo", …]
}
No parameters required.

Code

POST /api/hash Save code and return its hash

Request body

FieldTypeDescription
languagestringrequiredsql or php
codestringrequired*Source code (* optional for preloaded DBs)
sql_versionstringoptionalNeeded only when code is empty and DB is preloaded

Response

{ "hash": "d41d8cd98f00b204e9800998ecf8427e" }
Pass the hash as sqlses or phpses to the run endpoints.

Parameters

Execution

POST /api/sql/run Execute a SQL query

Request body

FieldTypeDescription
sql_versionstringrequiredKey from sql_versions
codestringrequiredSQL to execute
formatstringoptionaljson (default) or text
calculate_costbooloptionalInclude EXPLAIN cost

Response

{ "columns": ["id","name"], "rows": [[1,"Alice"]], "cost": "…" }

Parameters

POST /api/php/run Execute PHP code with optional SQL database

Request body

FieldTypeDescription
php_codestringrequiredPHP source to execute
php_versionstringoptionalDefault: php81
sql_versionstringoptionalProvisions a DB; injects $pdo, $mysqli, $db
sql_codestringoptionalSQL to run before PHP (schema/seed)

Response

{ "result": "Hello World\n" }
Also pass php_version as a query parameter so nginx routes straight to the right PHP-FPM: /api/php/run?php_version=php84. Without it the request takes an extra internal hop.

Parameters

POST /api/evaluatesql Execute a saved SQL session by hash

Request body

FieldTypeDescription
sql_versionstringrequiredKey from sql_versions
sqlsesstringrequiredSession hash from /api/hash
formatstringoptionaljson (default) or text
calculate_costbooloptionalInclude EXPLAIN cost

Response

{ "columns": ["id","name"], "rows": [[1,"Alice"]], "cost": "…" }
Pass sql_version as a query parameter too so nginx can route Firebird versions to the correct PHP backend: /api/evaluatesql?sql_version=firebird5

Parameters

POST /api/evaluatephp Execute a saved PHP session by hash

Request body

FieldTypeDescription
phpsesstringrequiredPHP session hash from /api/hash
php_versionstringoptionalDefault: php81
sql_versionstringoptionalProvisions a DB; injects $pdo, $mysqli, $db
sqlsesstringoptionalSQL session hash to run as schema/seed before PHP

Response

{ "result": "Hello World\n" }
Pass php_version as a query parameter so nginx routes to the correct PHP-FPM: /api/evaluatephp?php_version=php84

Parameters

ER Diagrams

GET /api/erd/{sql_version}/{session_hash} Generate an ER diagram for a session

Path parameters

ParameterDescription
sql_versionMust be in erd_support list
session_hashHash from a previous /api/hash call

Response

{ "erd": "<svg …>…</svg>" }

Path parameters

Error responses

{ "error": "Human-readable description" }

HTTP 422 — invalid or unsupported input
HTTP 404 — endpoint not found
HTTP 501 — not yet implemented
HTTP 500 — internal server error