PUZZGEN / API V1
A free puzzle API for learning to build games. Choose a kind and difficulty, save the returned seed, and turn simple JSON into your own interface. Start with the learning hub or working plain JavaScript game.
Download OpenAPI 3.1 · Live generator catalog and answer formats
curl -X POST http://127.0.0.1:8080/api/v1/generate \
-H 'Content-Type: application/json' \
-d '{"kind":"sudoku","seed":42,"difficulty":"medium"}'
In PowerShell, use Invoke-RestMethod:
Invoke-RestMethod http://127.0.0.1:8080/api/v1/generate `
-Method Post -ContentType application/json `
-Body '{"kind":"sudoku","seed":42,"difficulty":"medium"}'
Omit seed for a new puzzle. Seeds are unsigned 64-bit integers in requests and decimal strings in responses. JavaScript clients should use a bigint-aware serializer for values above 253−1. The Rust frontend preserves every bit. Difficulty selects a generation preset; it is not a calibrated human solving rating.
| Method | Path | Purpose |
|---|---|---|
| GET | /api/v1/catalog | Supported kinds, rules, guarantees, answer shapes |
| POST | /api/v1/generate | One puzzle; JSON kind, optional seed and difficulty |
| GET | /api/v1/puzzles/{kind} | One puzzle; optional seed, difficulty query parameters |
| POST | /api/v1/batch | 1–16 puzzles in a {"puzzles":[…]} body |
| GET | /api/v1/daily/{kind} | Daily seed; optional date=YYYY-MM-DD, difficulty |
| POST | /api/v1/verify | Check kind, seed, difficulty, answer; returns correct |
| GET | /health/live | Process liveness |
| GET | /health/ready | API readiness; no database required |
| GET | /metrics | Prometheus counters; key protected when configured |
| GET | /api/v1/openapi.json | Machine-readable API contract |
sudoku, mini-sudoku, maze, nonogram, word-search, sliding-puzzle, lights-out, minesweeper, arithmetic, and cryptogram. Each response states its rules and uniqueness guarantee. The catalog describes the answer format for each generator.
Solutions are omitted unless you explicitly set include_solution: true (or the equivalent query parameter). Send an answer in the catalog's format:
{"kind":"arithmetic","seed":42,"difficulty":"medium","answer":123}
Verification returns {"correct":true} or {"correct":false}. Invalid request structure returns a JSON error. Daily puzzles use UTC, and their date response includes the selected date. Replay requires the same kind, seed, difficulty, and generator version.
On member-enabled instances, create a free account and manage your profile and API keys. Regular accounts start with three active keys, 10 compute requests per minute, 100 puzzle operations per UTC day, one puzzle per batch, and one concurrent operation. These budgets are shared across all keys and the signed-in playground. Administrators can grant custom allocations. The session page displays your actual limits and usage.
fetch(`${apiOrigin}/api/v1/puzzles/maze?seed=42`, {
headers: { Authorization: `Bearer ${yourKey}` }
});Keys are shown once at creation. Revoke and replace them if exposed. Browser keys are visible to their users; never publish your private key in an example. Account management and administration require a browser session; API keys only authorize puzzle computation. The account page uses HttpOnly cookies and CSRF-protected mutations. OAuth and automated email recovery remain future additions.
This is personally funded: fetch on user actions, reuse data, and use fixtures while iterating. Cross-origin key requests support GET/POST and JSON preflights. Retry-After accompanies quota and capacity failures. Catalog, documentation, health, and offline lessons remain public. Deployments without member storage retain the legacy public/static-key mode with a default shared budget of 120 requests per minute.
A batch is one request and costs one daily operation per puzzle; answer verification also costs one operation. CPU capacity is bounded independently of account quotas. The server accepts at most 16 puzzles per batch and 64 KiB per request, with a 15-second HTTP budget. The account API is documented under the Accounts tag in the OpenAPI contract.
{"error":{"code":"quota_exceeded","message":"Your requests-per-minute limit has been reached"}}
Errors use 400 (invalid input), 401 (key required), 413 (body too large), 429 (rate budget), 503 (busy), or 504 (time budget). Retry-After accompanies 429 and 503. Unknown API routes return 404, unsupported methods return 405.
Seeds and reveal endpoints make this an open puzzle construction API. A competitive game needs a separate trusted game-session boundary that does not expose seeds or solutions to players.
Procedural generation offers a vast finite seed space, not a guarantee that every seed produces a different puzzle. See README.md for architecture, deployment, and the expansion roadmap.