API Documentation

Access knowledge packs programmatically via REST API

Authentication

Generate an API key in Settings. Pass it in the x-api-key header.

curl -H "x-api-key: cxl_your_key_here" \
  https://codexlib.io/api/v1/packs

Rate limits: Free = 10 requests/day, Pro = 1,000 requests/day

GET /api/v1/packs

List and search knowledge packs

Query Parameters

ParamTypeDescription
domainstringFilter by domain slug
searchstringSearch by title
difficultystringbeginner | intermediate | advanced | expert
pagenumberPage number (default: 1)
limitnumberResults per page (default: 20, max: 100)
curl "https://codexlib.io/api/v1/packs?domain=medicine&difficulty=intermediate&limit=10" \
  -H "x-api-key: cxl_your_key"

GET /api/v1/packs/:id

Get a single knowledge pack by ID or slug

curl "https://codexlib.io/api/v1/packs/med-cardiology-001" \
  -H "x-api-key: cxl_your_key"

Free users see 20% preview. Pro users get full content + rosetta decoder.

GET /api/v1/packs/download

Bulk download packs (Pro only)

curl "https://codexlib.io/api/v1/packs/download?domain=ai-ml" \
  -H "x-api-key: cxl_your_key"

Returns up to 100 full packs per request. Pro subscription required.

Knowledge Pack Format

{
  "id": "med-cardiology-001",
  "title": "Cardiology Fundamentals",
  "domain": "Medicine",
  "subdomain": "Cardiology",
  "version": "1.0.0",
  "compression": "tokenshrink-v2",
  "token_count": 2847,
  "uncompressed_estimate": 3400,
  "savings_pct": 16.3,
  "rosetta": "[DECODE] heart=cardiac organ|bp=blood pressure|...",
  "content": "## Cardiac Anatomy\nheart: 4-chamber muscular organ...",
  "difficulty": "intermediate"
}

The rosetta field contains the decoder header. Paste it into any AI system prompt to decompress the content on-the-fly.