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.

🌐
Base URL
https://legion-registry.pages.dev/api/v1
🔐
Auth
Bearer lgn_… tokens
📊
Format
JSON, UTF-8
Hosting
Cloudflare Pages

Authentication

POST
/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", … } }
POST
/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"}'
GET
/auth/me 🔑 auth

Get the authenticated user's profile.

Packages

GET
/packages

List all packages. Query params: sort (downloads|name|recent|newest|score), page, limit (max 100), q (filter).

GET
/packages/:name

Get full package metadata. Increments download count.

GET
/packages/:name/versions

List all published versions with timestamps.

GET
/packages/:name/readme

Get the package README as raw Markdown.

GET
/packages/:name/changelog

Get the package version changelog entries.

GET
/packages/:name/score

Get the package quality score (0–100) with breakdown.

GET
/packages/:name/:version/download

Get download metadata for a specific version. Use latest for the latest version.

POST
/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"}}
DELETE
/packages/unpublish 🔑 auth

Unpublish a package you own. Body: {"name":"legion-mylib"}

Badges

GET
/packages/:name/badge

Get an SVG badge for a package. Query param type: version (default), downloads, license, score.

# Version badge ![legion-http](https://legion-registry.pages.dev/api/v1/packages/legion-http/badge?type=version) # Downloads badge ![legion-http](https://legion-registry.pages.dev/api/v1/packages/legion-http/badge?type=downloads) # Quality score badge ![legion-http](https://legion-registry.pages.dev/api/v1/packages/legion-http/badge?type=score)

Users

GET
/users/:username

Get public user profile.

GET
/users/:username/packages

Get all Legion packages published by a user.

Tokens

GET
/tokens🔑 auth

List your API tokens (shows prefix only).

POST
/tokens🔑 auth

Create a new token. Body: {"name":"CI token","scopes":["read","publish"]}. Returns full token (shown once).

DELETE
/tokens/:id🔑 auth

Revoke a token by its short ID (last 8 chars).

Stats

GET
/stats

Registry-wide statistics: total packages, downloads, users, popular packages.

{ "success": true, "packages": 8, "downloads": 23000, "users": 3, "popular": […] }

Audit

POST
/audit

Check 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 package
legion pkg install <pkg>@<ver>Install a specific version
legion pkg install <pkg> -DInstall as dev dependency
legion pkg remove <pkg>Uninstall a package
legion pkg updateUpdate all packages
legion pkg outdatedShow outdated packages
legion pkg listList installed packages
legion pkg list --depth=2List with dependency tree
legion pkg search <query>Search the registry
legion pkg info <pkg>Show package metadata
legion pkg init [name]Initialize a new project
legion pkg publishPublish to the registry
legion pkg loginAuthenticate (interactive)
legion pkg login --token lgn_…Authenticate with token
legion pkg whoamiShow current user
legion pkg logoutClear stored credentials
legion pkg auditSecurity audit
legion pkg run <script>Run npm-style scripts
legion pkg ciClean install from lockfile
legion pkg packCreate .tar.gz archive
legion pkg linkSymlink package globally
legion pkg doctorDiagnose environment

Error codes

StatusMeaning
400Bad request — invalid input or missing fields
401Unauthorized — token missing or invalid
403Forbidden — you don't own this resource
404Not found — package or user doesn't exist
409Conflict — username taken or version already published
429Rate limited — too many requests, try again in 60s
500Server error — report to the legion team