Skip to main content

Lexicon Hub

Package registry for sharing and discovering Chaos Cypher knowledge packages. Supports device authorization (OAuth 2.0 RFC 8628), username/password login, and direct token authentication for CI/automation.

Base path: /api/v1/lexicon


Authentication

Initiate Device Authorization

POST /api/v1/lexicon/auth/device

Starts an OAuth 2.0 Device Authorization Grant flow (RFC 8628). Returns a user code and verification URL for the user to complete authentication in a browser.

Request Body

FieldTypeRequiredDefaultDescription
lexicon_urlstringNoLEXICON_URL env var or http://localhost:3001Lexicon server URL
client_idstringNochaoscypherOAuth client identifier
scopestringNoread writeRequested OAuth scopes

Example

curl -X POST "http://localhost:8080/api/v1/lexicon/auth/device" \
-H "Content-Type: application/json" \
-d '{
"lexicon_url": "http://localhost:3001",
"client_id": "chaoscypher",
"scope": "read write"
}'

Response

200 OK

{
"device_code": "d1b2c3d4-e5f6-7890-abcd-ef1234567890",
"user_code": "ABCD-1234",
"verification_uri": "http://localhost:3001/device",
"verification_uri_complete": "http://localhost:3001/device?code=ABCD-1234",
"expires_in": 900,
"interval": 5
}
LexiconDeviceCodeResponse
FieldTypeDescription
device_codestringCode for polling the token endpoint
user_codestringCode the user enters at the verification URL
verification_uristringURL where the user completes auth
verification_uri_completestring/nullURL with the user code pre-filled
expires_inintSeconds until the codes expire (default: 900)
intervalintMinimum polling interval in seconds (default: 5)

Poll for Device Token

POST /api/v1/lexicon/auth/poll

Single non-blocking poll to check whether the user has completed browser authentication. Returns immediately with a success or pending status.

Request Body

FieldTypeRequiredDefaultDescription
device_codestringYes--Device code from the initial request
lexicon_urlstringNoLEXICON_URL env var or http://localhost:3001Lexicon server URL
client_idstringNochaoscypherOAuth client identifier

Example

curl -X POST "http://localhost:8080/api/v1/lexicon/auth/poll" \
-H "Content-Type: application/json" \
-d '{
"device_code": "d1b2c3d4-e5f6-7890-abcd-ef1234567890",
"lexicon_url": "http://localhost:3001",
"client_id": "chaoscypher"
}'

Response -- Pending

200 OK

{
"success": false,
"username": null,
"lexicon_url": "http://localhost:3001",
"message": "Authorization pending - user has not completed auth"
}

Response -- Success

200 OK

{
"success": true,
"username": "johndoe",
"lexicon_url": "http://localhost:3001",
"message": "Successfully authenticated"
}

Error Responses

StatusCondition
403Access denied by user
408Device code expired

Login with Username and Password

POST /api/v1/lexicon/auth/login

Authenticates with the Lexicon using username and password credentials.

Request Body

FieldTypeRequiredDefaultDescription
usernamestringYes--Lexicon username
passwordstringYes--Lexicon password
lexicon_urlstringNoLEXICON_URL env var or http://localhost:3001Lexicon server URL

Example

curl -X POST "http://localhost:8080/api/v1/lexicon/auth/login" \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"password": "s3cret"
}'

Response

200 OK

{
"success": true,
"username": "johndoe",
"lexicon_url": "http://localhost:3001",
"message": "Successfully logged in"
}
LexiconAuthResponse
FieldTypeDescription
successboolWhether the operation succeeded
usernamestring/nullAuthenticated username (if applicable)
lexicon_urlstringLexicon URL used for the operation
messagestringHuman-readable status message

Error Responses

StatusCondition
401Invalid credentials
503Lexicon server unavailable

Set Token Directly

POST /api/v1/lexicon/auth/token

Sets a JWT access token directly, bypassing interactive login. Designed for CI/CD pipelines and automation.

Request Body

FieldTypeRequiredDefaultDescription
tokenstringYes--JWT access token
usernamestring/nullNonullOptional username (for display)
lexicon_urlstringNoLEXICON_URL env var or http://localhost:3001Lexicon server URL

Example

curl -X POST "http://localhost:8080/api/v1/lexicon/auth/token" \
-H "Content-Type: application/json" \
-d '{
"token": "eyJhbGciOiJIUzI1NiIs...",
"username": "ci-bot"
}'

Response

200 OK

{
"success": true,
"username": "ci-bot",
"lexicon_url": "http://localhost:3001",
"message": "Token saved successfully"
}

Logout

POST /api/v1/lexicon/auth/logout

Clears all stored Lexicon credentials.

Example

curl -X POST "http://localhost:8080/api/v1/lexicon/auth/logout"

Response

200 OK

{
"success": true,
"username": null,
"lexicon_url": "http://localhost:3001",
"message": "Successfully logged out"
}

Get Auth Status

GET /api/v1/lexicon/auth/status

Returns the current authentication status without making any external requests.

Example

curl "http://localhost:8080/api/v1/lexicon/auth/status"

Response -- Authenticated

200 OK

{
"authenticated": true,
"username": "johndoe",
"lexicon_url": "http://localhost:3001",
"token_present": true
}

Response -- Not Authenticated

200 OK

{
"authenticated": false,
"username": null,
"lexicon_url": "http://localhost:3001",
"token_present": false
}
LexiconAuthStatus
FieldTypeDescription
authenticatedboolWhether the user is authenticated
usernamestring/nullAuthenticated username (if any)
lexicon_urlstring/nullConfigured Lexicon URL
token_presentboolWhether a token is currently stored

Packages

Search Packages

GET /api/v1/lexicon/search

Search for packages on the Lexicon registry. An empty query returns all packages.

Query Parameters

ParameterTypeRequiredDefaultDescription
querystringNo""Search query string (empty returns all)
pageintNo1Page number (1-indexed, minimum: 1)
limitint/nullNoserver default (50)Results per page (minimum: 1, capped at server max: 1000)
sort_bystringNodownloadsSort field: relevance, stars, downloads, newest, updated, name
is_publicbool/nullNonullFilter by visibility (true or false)
owner_idstring/nullNonullFilter by owner ID
package_typestring/nullNonullFilter by type: FULL, TEMPLATES, KNOWLEDGE, WORKFLOWS, MIXED

Examples

# Search all packages
curl "http://localhost:8080/api/v1/lexicon/search"

# Search by keyword
curl "http://localhost:8080/api/v1/lexicon/search?query=medical"

# Search with filters
curl "http://localhost:8080/api/v1/lexicon/search?query=finance&sort_by=stars&is_public=true&package_type=KNOWLEDGE"

# Paginated results
curl "http://localhost:8080/api/v1/lexicon/search?query=science&page=2&limit=10"

Response

200 OK

{
"packages": [
{
"id": "repo-abc123",
"name": "medical-ontology",
"description": "Comprehensive medical knowledge graph with ICD-10 mappings",
"owner_username": "johndoe",
"owner_name": "John Doe",
"owner_id": "user-xyz789",
"is_public": true,
"package_type": "KNOWLEDGE",
"star_count": 42,
"version_count": 3,
"download_count": 1250,
"created_at": 1704067200000,
"updated_at": 1709251200000
}
],
"total": 1,
"page": 1,
"limit": 50
}
LexiconSearchResponse
FieldTypeDescription
packagesLexiconPackageInfo[]Array of matching packages
totalintTotal number of matches
pageintCurrent page number
limitintResults per page
LexiconPackageInfo
FieldTypeDescription
idstringUnique repository ID
namestringRepository/package name
descriptionstringPackage description
owner_usernamestringOwner's username
owner_namestringOwner's display name
owner_idstringOwner's user ID
is_publicboolPublic visibility
package_typestringPackage type: FULL, TEMPLATES, KNOWLEDGE, WORKFLOWS, MIXED
star_countintNumber of stars
version_countintNumber of published versions
download_countintTotal downloads across all versions
created_atintCreation timestamp (Unix milliseconds)
updated_atintLast update timestamp (Unix milliseconds)

Get Package Info

GET /api/v1/lexicon/r/{owner}/{name}

Retrieve metadata for a specific package by owner and name.

Path Parameters

ParameterTypeRequiredDescription
ownerstringYesPackage owner's username
namestringYesRepository/package name

Example

curl "http://localhost:8080/api/v1/lexicon/r/johndoe/medical-ontology"

Response

200 OK

{
"id": "repo-abc123",
"name": "medical-ontology",
"description": "Comprehensive medical knowledge graph with ICD-10 mappings",
"owner_username": "johndoe",
"owner_name": "John Doe",
"owner_id": "user-xyz789",
"is_public": true,
"package_type": "KNOWLEDGE",
"star_count": 42,
"version_count": 3,
"download_count": 1250,
"created_at": 1704067200000,
"updated_at": 1709251200000
}

Error Responses

StatusCondition
404Package not found

Import Package

POST /api/v1/lexicon/import

Queue a Lexicon package import from the registry into the current Chaos Cypher database. The operation runs asynchronously in the background — poll the returned task_id via GET /api/v1/queue/tasks/{task_id} to track progress.

Request Body

FieldTypeRequiredDefaultDescription
owner_usernamestringYes--Lexicon package owner username
repo_namestringYes--Lexicon package repository name
versionstringNo"latest"Package version tag
{
"owner_username": "acme",
"repo_name": "research-graph",
"version": "latest"
}

Response

Status: 202 Accepted

{
"message": "Import of acme/research-graph queued. Check Queue Monitor for status.",
"task_id": "task-abc123def456",
"status": "queued",
"owner_username": "acme",
"repo_name": "research-graph",
"version": "latest"
}
FieldTypeDescription
messagestringHuman-readable status message
task_idstringQueue task ID to poll for progress
statusstringInitial task status ("queued")
owner_usernamestringPackage owner
repo_namestringPackage repository name
versionstringPackage version being imported

curl Example

curl -X POST http://localhost:8080/api/v1/lexicon/import \
-H "Content-Type: application/json" \
-d '{
"owner_username": "acme",
"repo_name": "research-graph",
"version": "latest"
}'

Errors

StatusDescription
503Queue service unavailable

Upload Package

POST /api/v1/lexicon/upload

Upload a package archive (.ccx) to the Lexicon registry. Requires authentication.

Request

Multipart form upload with query parameters for metadata.

Query Parameters

ParameterTypeRequiredDefaultDescription
publicboolNotrueMake package publicly visible
messagestring/nullNonullOptional upload/commit message

File Field

FieldTypeRequiredDescription
fileUploadFileYesPackage archive file (.ccx)

Example

curl -X POST "http://localhost:8080/api/v1/lexicon/upload?public=true&message=Initial+release" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-F "file=@my-package.ccx"

Response

200 OK

{
"id": "repo-def456",
"name": "my-package",
"description": "My knowledge package",
"owner_username": "johndoe",
"owner_name": "John Doe",
"owner_id": "user-xyz789",
"is_public": true,
"package_type": "FULL",
"star_count": 0,
"version_count": 1,
"download_count": 0,
"created_at": 1709251200000,
"updated_at": 1709251200000
}

Error Responses

StatusCondition
401Authentication required
403Insufficient permissions
503Lexicon server unavailable

Error Handling

All Lexicon endpoints return errors in a consistent format:

{
"detail": {
"message": "Human-readable error message",
"details": {}
}
}

Status Code Mapping

Errors from the upstream Lexicon server are mapped to HTTP status codes:

Upstream StatusAPI StatusMeaning
401401Unauthorized
403403Forbidden
404404Not found
408408Request timeout
410408Gone (code expired)
Other503Service unavailable