Main client for loading LAP documents.
from lap import LAPClient
client = LAPClient()Load a .lap file and return a queryable document.
doc = client.load("output/stripe-charges.lap")Raises FileNotFoundError if the file doesn't exist.
A loaded LAP document with query and formatting methods.
| Property | Type | Description |
|---|---|---|
api_name |
str |
API name from @api directive |
base_url |
str |
Base URL from @base directive |
version |
str |
Version from @version directive |
endpoints |
List[EndpointInfo] |
All endpoints in the spec |
Find an endpoint by HTTP method and path.
ep = doc.get_endpoint("POST", "/v1/charges")Format the full spec as a string for LLM context injection.
context = doc.to_context(lean=True)
# Inject into prompt: f"API Reference:\n{context}"Count tokens using tiktoken.
tokens = doc.token_count(lean=True)
print(f"{tokens} tokens")Structured endpoint data.
| Property | Type | Description |
|---|---|---|
method |
str |
HTTP method (GET, POST, etc.) |
path |
str |
URL path |
summary |
str |
Description from @desc |
required_params |
List[Param] |
Required parameters |
optional_params |
List[Param] |
Optional parameters |
request_body |
List[Param] |
Request body fields |
response_schemas |
List[ResponseSchema] |
Response schemas |
response_schema |
Optional[ResponseSchema] |
Primary (first) response |
error_schemas |
List[ErrorSchema] |
Error definitions |
Parameter definition.
| Property | Type | Description |
|---|---|---|
name |
str |
Parameter name |
type |
str |
Type string (str, int, etc.) |
required |
bool |
Whether required |
description |
str |
Description text |
enum |
list |
Enum values (if any) |
default |
Optional[str] |
Default value |
Local registry for browsing LAP files in a directory.
from lap import Registry
registry = Registry("output/")List all available spec names.
names = registry.list()
# ['asana', 'box', 'cloudflare', 'discord', 'github-core', ...]Get a spec by name (exact or partial match).
doc = registry.get("stripe")Search across all specs by name or content.
results = registry.search("webhook")LangChain-compatible document loader.
from lap.middleware import LAPDocLoader
loader = LAPDocLoader("output/stripe.lap", lean=True)
docs = loader.load() # List[Document] — one per endpoint
full = loader.load_full() # List[Document] — single document with full contextimport { LAPClient } from '@lap-platform/lapsh';
const client = new LAPClient();Load a .lap file from disk.
const spec = client.loadFile('output/stripe-charges.lap');Parse a LAP string directly.
const spec = client.loadString(lapText);Fetch a spec from a registry server.
const spec = await client.fromRegistry('http://localhost:8420', 'stripe-charges');| Property | Type | Description |
|---|---|---|
apiName |
string |
API name |
baseUrl |
string |
Base URL |
version |
string |
API version |
auth |
string |
Auth scheme |
endpoints |
Endpoint[] |
All endpoints |
| Property | Type | Description |
|---|---|---|
method |
string |
HTTP method |
path |
string |
URL path |
description |
string |
Description |
requiredParams |
Param[] |
Required parameters |
optionalParams |
Param[] |
Optional parameters |
responses |
ResponseSchema[] |
Response schemas |
| Property | Type | Description |
|---|---|---|
name |
string |
Parameter name |
type |
string |
Type string |
nullable |
boolean |
Is nullable |
isArray |
boolean |
Is array type |
enumValues |
string[] |
Enum values |
defaultValue |
string |
Default value |
description |
string |
Description |
Format a spec for LLM context injection.
import { toContext } from '@lap-platform/lapsh';
const context = toContext(spec, { lean: true });
const filtered = toContext(spec, {
endpoints: ['POST /v1/charges']
});The registry at lap.sh exposes a REST API.
List all available specs.
Response: 200 OK
{
"specs": [
{
"name": "stripe-charges",
"description": "Stripe Charges API",
"version": "2024-12-18",
"endpoints": 5,
"size": 4291,
"lean_size": 1847,
"last_updated": "2026-02-08T00:00:00+00:00"
}
]
}Get the raw LAP text for a spec.
Query params: format=lean for lean version.
Response: 200 OK — raw LAP text (text/plain)
Get metadata for a spec.
Response: 200 OK
{
"name": "stripe-charges",
"description": "Stripe Charges API",
"version": "2024-12-18",
"base_url": "https://api.stripe.com",
"endpoints": 5
}Search across all specs.
Response: 200 OK — array of matching specs