IdleLingo API
API Documentation
Reference for integrating apps and learning tools with the IdleLingo platform.
Overview
IdleLingo is an API-first platform for Japanese and Chinese character learning. Client applications integrate through structured HTTP endpoints for accounts, player sessions, world state, inventory, and progression data.
All API responses use JSON. Successful responses include "success": true. Errors return an appropriate HTTP status with "success": false, an error_code, and a message.
Base URLs
http://127.0.0.1:5000
https://idlelingo.com
Authentication
IdleLingo supports two authentication layers:
Account sessions — Flask-Login cookie sessions created via POST /api/auth/register or POST /api/auth/login. Required for /api/auth/logout and /api/auth/me.
Player sessions — Bearer tokens issued by POST /api/players/session. Pass the token via Authorization: Bearer <token>, the X-Session-Token header, or a session_token field in the JSON body. Required for player, world, and inventory endpoints marked Player session below.
Health & Observability
IdleLingo exposes two health endpoints: a human-facing service status page and a machine-readable JSON endpoint for integrations and health monitors.
GET /health is the public availability page with friendly service indicators. GET /api/health returns JSON and preserves ok and service for existing clients.
Responses include current service status, database connectivity, timestamps, and version metadata.
Every response includes an X-Request-ID header. Clients may send the same header to correlate their logs with IdleLingo server logs. The value is reused when safe; otherwise the server generates a short ID.
API request summaries are logged safely by default — passwords, tokens, cookies, Authorization headers, and session secrets are never written to logs. Optional payload logging is disabled by default (IDLELINGO_API_LOG_PAYLOADS=false) and only records sanitized JSON when explicitly enabled.
/health
/api/health
Client Applications
/api/clients
/api/clients/<client_id>
Accounts
/api/auth/register
/api/auth/login
/api/auth/logout
/api/auth/me
Sessions
/api/players/session
Player / Profile Data
/api/players/me
Inventory
/api/players/me/inventory
Drops / Rewards
/api/worlds/<world_id>/items/drop
/api/worlds/<world_id>/items/pickup
Learning Models
Learning content and per-learner glyph progress are persisted through LearningGlyph, PlayerGlyphProgress, and QuestProgress models.
Clients integrate character literacy and progression through player sessions, world state, inventory, and the account workflows documented in this reference.
Worlds
/api/worlds
/api/worlds/status
/api/worlds/<world_id>/join
/api/worlds/<world_id>/heartbeat
/api/worlds/<world_id>/state
/api/worlds/<world_id>/scenes/<scene_key>/state
Error Format
Failed requests return JSON with HTTP 4xx or 5xx status codes:
{
"success": false,
"error_code": "UNAUTHORIZED",
"message": "Missing or invalid session token."
}
Example Requests
Create a player session
curl -X POST http://127.0.0.1:5000/api/players/session \
-H "Content-Type: application/json" \
-d '{"username": "adventurer", "client_application_id": "kanji_slayer"}'
Join a world
curl -X POST http://127.0.0.1:5000/api/worlds/world_1/join \
-H "Authorization: Bearer <session_token>" \
-H "Content-Type: application/json"
Fetch player inventory
curl http://127.0.0.1:5000/api/players/me/inventory \
-H "Authorization: Bearer <session_token>"
Versioning
The IdleLingo API is unversioned. All paths are prefixed with /api/.
This reference documents the current public API surface for accounts, sessions, worlds, inventory, learning models, and platform health.