Legion Registry API
Base URL: https://legion-registry.pages.dev/api/v1
All endpoints return JSON. Authenticated endpoints require Authorization: Bearer lgn_…
Full CORS support. Rate limit: 20 POST requests/minute per IP.
Overview
The Legion Registry REST API lets you programmatically query packages, manage accounts, publish packages, and integrate Legion package data into your tools.
https://legion-registry.pages.dev/api/v1
Bearer lgn_… tokens
JSON, UTF-8
Cloudflare Pages
Authentication
/auth/signup
Create a new account. Returns an API token.
curl -X POST https://legion-registry.pages.dev/api/v1/auth/signup \
-H "Content-Type: application/json" \
-d '{"username":"alice","email":"alice@example.com","password":"hunter2xx"}'{ "success": true, "token": "lgn_…", "user": { "username": "alice", … } }/auth/login
Login and get a Legion API token.
curl -X POST https://legion-registry.pages.dev/api/v1/auth/login \
-d '{"username":"alice","password":"hunter2xx"}'/auth/me
🔑 auth
Get the authenticated user's profile.
Packages
/packages
List all packages. Query params: sort (downloads|name|recent|newest|score), page, limit (max 100), q (filter).
/packages/:name
Get full package metadata. Increments download count.
/packages/:name/versions
List all published versions with timestamps.
/packages/:name/readme
Get the package README as raw Markdown.
/packages/:name/changelog
Get the package version changelog entries.
/packages/:name/score
Get the package quality score (0–100) with breakdown.
/packages/:name/:version/download
Get download metadata for a specific version. Use latest for the latest version.
/packages/publish
🔑 auth
Publish a new package or version. Body:
{"name":"legion-mylib","version":"1.0.0","description":"…","license":"MIT","keywords":["legion","http"],"readme":"# …","changelog":"Initial release","dependencies":{"legion-http":"^1.0.0"}}/packages/unpublish
🔑 auth
Unpublish a package you own. Body: {"name":"legion-mylib"}
Search
/search?q=:query&limit=20
Full-text search with relevance scoring. Searches name, description, keywords, and author. Returns ranked results with quality scores.
curl "https://legion-registry.pages.dev/api/v1/search?q=http&limit=10"Trending
/trending
Top 10 trending packages ranked by download velocity (downloads per day since publish). Updated in real-time.
{ "success": true, "trending": [{ "rank": 1, "name": "legion-http", "velocity": 23.4, … }] }Badges
/packages/:name/badge
Get an SVG badge for a package. Query param type: version (default), downloads, license, score.
# Version badge

# Downloads badge

# Quality score badge
Users
/users/:usernameGet public user profile.
/users/:username/packagesGet all Legion packages published by a user.
Tokens
/tokens🔑 authList your API tokens (shows prefix only).
/tokens🔑 authCreate a new token. Body: {"name":"CI token","scopes":["read","publish"]}. Returns full token (shown once).
/tokens/:id🔑 authRevoke a token by its short ID (last 8 chars).
Stats
/statsRegistry-wide statistics: total packages, downloads, users, popular packages.
{ "success": true, "packages": 8, "downloads": 23000, "users": 3, "popular": […] }Audit
/auditCheck your dependencies for issues. Body: {"dependencies":{"legion-http":"^1.0.0"}}
{ "success": true, "advisories": [], "scanned": 1, "clean": true }CLI Reference
Full legion pkg CLI — 20 commands, npm-quality package management for legionhjyu.
legion pkg install <pkg>Install a packagelegion pkg install <pkg>@<ver>Install a specific versionlegion pkg install <pkg> -DInstall as dev dependencylegion pkg remove <pkg>Uninstall a packagelegion pkg updateUpdate all packageslegion pkg outdatedShow outdated packageslegion pkg listList installed packageslegion pkg list --depth=2List with dependency treelegion pkg search <query>Search the registrylegion pkg info <pkg>Show package metadatalegion pkg init [name]Initialize a new projectlegion pkg publishPublish to the registrylegion pkg loginAuthenticate (interactive)legion pkg login --token lgn_…Authenticate with tokenlegion pkg whoamiShow current userlegion pkg logoutClear stored credentialslegion pkg auditSecurity auditlegion pkg run <script>Run npm-style scriptslegion pkg ciClean install from lockfilelegion pkg packCreate .tar.gz archivelegion pkg linkSymlink package globallylegion pkg doctorDiagnose environmentError codes
| Status | Meaning |
|---|---|
| 400 | Bad request — invalid input or missing fields |
| 401 | Unauthorized — token missing or invalid |
| 403 | Forbidden — you don't own this resource |
| 404 | Not found — package or user doesn't exist |
| 409 | Conflict — username taken or version already published |
| 429 | Rate limited — too many requests, try again in 60s |
| 500 | Server error — report to the legion team |