Proxy Configuration
The L402 Proxy allows you to monetize any API - yours or third-party - by creating a payment-gated reverse proxy.
Overview
The proxy sits between clients and target APIs:
Client → L402 Proxy → Target API
│
└─ Requires Lightning payment
Use cases:
- Monetize your own APIs without modifying them
- Resell third-party APIs with a markup
- Create premium access to public APIs
- Rate-limit expensive APIs via micropayments
Creating a Proxy
Via API
curl -X POST https://api.lightningenable.com/api/proxy \
-H "X-API-Key: your-merchant-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "Premium Weather API",
"targetBaseUrl": "https://api.weather.com/v1",
"defaultPriceSats": 10,
"description": "Weather data with Lightning payments"
}'
Response:
{
"proxyId": "premium-weather-api-a1b2",
"name": "Premium Weather API",
"targetBaseUrl": "https://api.weather.com/v1",
"defaultPriceSats": 10,
"isActive": true,
"createdAt": "2024-12-29T12:00:00Z"
}
Proxy Endpoint
Your proxy is now available at:
https://api.lightningenable.com/l402/proxy/{proxyId}/{path}
For example:
https://api.lightningenable.com/l402/proxy/premium-weather-api-a1b2/forecast?city=nyc
Configuration Options
Full Configuration
{
"name": "Premium Weather API",
"description": "Weather data via Lightning payments",
"targetBaseUrl": "https://api.weather.com/v1",
"defaultPriceSats": 10,
"isActive": true,
"authHeader": "X-Api-Key",
"authValue": "your-weather-api-key",
"timeout": 30,
"allowedMethods": ["GET", "POST"],
"allowedPaths": ["/forecast/*", "/current/*"],
"blockedPaths": ["/admin/*"]
}
Configuration Reference
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for the proxy |
targetBaseUrl | string | Yes | Base URL of target API |
defaultPriceSats | int | Yes | Default price per request |
description | string | No | Proxy description |
isActive | bool | No | Enable/disable proxy (default: true) |
authHeader | string | No | Header name for target API auth |
authValue | string | No | Header value for target API auth |
timeout | int | No | Request timeout in seconds (default: 30) |
allowedMethods | array | No | Allowed HTTP methods |
allowedPaths | array | No | Path whitelist (glob patterns) |
blockedPaths | array | No | Path blacklist (glob patterns) |
Endpoint-Specific Pricing
Set different prices for different endpoints:
curl -X POST https://api.lightningenable.com/api/proxy/{proxyId}/pricing \
-H "X-API-Key: your-merchant-api-key" \
-H "Content-Type: application/json" \
-d '{
"pathPattern": "/forecast/7day",
"priceSats": 50,
"description": "7-day forecast (premium)"
}'
Multiple Price Tiers
# Add pricing for different endpoints
curl -X POST .../pricing -d '{"pathPattern": "/current/*", "priceSats": 5}'
curl -X POST .../pricing -d '{"pathPattern": "/forecast/1day", "priceSats": 10}'
curl -X POST .../pricing -d '{"pathPattern": "/forecast/7day", "priceSats": 50}'
curl -X POST .../pricing -d '{"pathPattern": "/historical/*", "priceSats": 100}'
Price Matching Priority
Prices are matched in order of specificity:
- Exact path match
- Glob pattern match (most specific first)
- Default proxy price