| name | lnget |
| version | 0.2.0 |
| description | HTTP client with automatic L402 Lightning micropayment support |
| metadata | {"openclaw":{"requires":{"bins":["lnget"]},"capabilities":["http_download","l402_payment","token_management","event_logging"],"interfaces":["cli","mcp"],"input_format":"json","output_format":"json","auth_methods":["lnd_macaroon","lnc_pairing","env_vars"]}} |
lnget
Download files with automatic L402 Lightning micropayments. When a server
returns HTTP 402 Payment Required with an L402 challenge, lnget pays the
Lightning invoice and retries the request automatically.
Tokens are cached per-domain so subsequent requests reuse them without
additional payments.
Installation
go install github.com/lightninglabs/lnget/cmd/lnget@latest
make install
Quick Reference
lnget --json --print-body https://api.example.com/data.json
lnget -q https://api.example.com/data.json | jq .
lnget -o - https://api.example.com/data.json
lnget --dry-run https://api.example.com/paid-endpoint
lnget --json --params '{"url": "https://api.example.com/data", "max_cost": 500}'
lnget schema --all
Key Rules for Agents
- Always use
--json for machine-readable output
- Use
--dry-run first before making payments to preview cost
- Use
--print-body with --json to get response content inline
- Use
-q or -o - when you only want the raw response body
- Use
--fields on list commands to limit output to needed fields
- Use
--force on destructive commands (tokens clear) in non-TTY mode
- Check
lnget schema <command> for parameter details
Output Modes
lnget has three distinct output modes. Understanding them prevents the
common mistake of expecting the response body from --json.
--json (metadata mode)
Returns structured metadata about the download. Does NOT include the
response body by default.
$ lnget --json https://example.com/price/USD
{
"url": "https://example.com/price/USD",
"output_path": "USD",
"size": 67,
"content_type": "application/json",
"status_code": 200,
"l402_paid": false,
"duration": "431ms",
"duration_ms": 430
}
--json --print-body (metadata + body)
Includes the response body as a "body" field in the JSON output.
Only works for text content types under 1MB.
$ lnget --json --print-body https://example.com/price/USD
{
"url": "https://example.com/price/USD",
"output_path": "USD",
"size": 67,
"content_type": "application/json",
"status_code": 200,
"l402_paid": false,
"duration": "431ms",
"duration_ms": 430,
"body": "{\"USD\":98234.50}"
}
-q or -o - (raw body to stdout)
Pipes the response body directly to stdout with no metadata.
Best for piping into jq or other processors.
$ lnget -q https://example.com/price/USD
{"USD":98234.50}
$ lnget -o - https://example.com/price/USD
{"USD":98234.50}
Dry-Run Mode
Always preview before paying:
$ lnget --dry-run https://api.example.com/paid-endpoint
{
"dry_run": true,
"url": "https://api.example.com/paid-endpoint",
"has_cached_token": false,
"requires_l402": true,
"invoice_amount_sat": 100,
"within_budget": true,
"max_cost_sats": 1000
}
Exit code 10 on success (no action taken).
Payment Control
lnget --max-cost 500 https://api.example.com/data
lnget --max-fee 5 https://api.example.com/data
lnget --no-pay https://api.example.com/data
Agent-First JSON Input
Use --params for structured request specification:
lnget --json --params '{
"url": "https://api.example.com/data",
"method": "POST",
"headers": {"Content-Type": "application/json"},
"data": "{\"query\": \"value\"}",
"max_cost": 500,
"max_fee": 5
}'
Token Management
lnget tokens list --json --fields domain,amount_sat --limit 10
lnget tokens list --ndjson
lnget tokens show example.com --json
lnget tokens remove example.com
lnget tokens clear --force
Lightning Backend
lnget ln status --json
lnget ln info --json
echo "word1 word2 ... word10" | lnget ln lnc pair --stdin
lnget ln lnc sessions --json
Schema Introspection
lnget schema
lnget schema tokens
lnget schema --all
Exit Codes
| Code | Meaning |
|---|
| 0 | Success |
| 1 | General error |
| 2 | Invalid arguments or payment too expensive |
| 3 | L402 payment failed |
| 4 | Network or connection error |
| 5 | Authentication failure |
| 6 | Rate limited |
| 10 | Dry-run completed (no action taken) |
Error Format
Errors are JSON on stderr:
{"error": true, "code": "payment_failed", "message": "no route found", "exit_code": 3}
Configuration
Config file: ~/.lnget/config.yaml
lnget config show --json
lnget config set --from-json '{"l402": {"max_cost_sats": 5000}}'
lnget config set l402.max_cost_sats 5000
lnget config init
Environment Variables
export LNGET_LN_MODE=lnd
export LNGET_LN_LND_HOST=localhost:10009
export LNGET_LN_LND_TLS_CERT=/path/to/tls.cert
export LNGET_LN_LND_MACAROON=/path/to/admin.macaroon
export LNGET_LN_LNC_PAIRING_PHRASE="word1 word2 ... word10"
MCP Integration
Expose lnget as typed MCP tools for agent frameworks:
lnget mcp serve
Available tools: download, dry_run, tokens_list, tokens_show,
tokens_remove, ln_status, events_list, events_stats, config_show.
Common Agent Patterns
Fetch and parse JSON API response
body=$(lnget -q https://api.example.com/data)
echo "$body" | jq '.result'
Check cost before paying
result=$(lnget --dry-run https://api.example.com/paid)
amount=$(echo "$result" | jq '.invoice_amount_sat')
if [ "$amount" -lt 500 ]; then
lnget --json --print-body https://api.example.com/paid
fi
Check if domain has cached token
if lnget tokens show example.com --json >/dev/null 2>&1; then
echo "Token cached, no payment needed"
fi
Download with progress to file
lnget -o large-file.zip https://api.example.com/file.zip
Resume interrupted download
lnget -c -o large-file.zip https://api.example.com/file.zip
File Locations
| Path | Description |
|---|
~/.lnget/config.yaml | Configuration file |
~/.lnget/tokens/<domain>/ | Cached L402 tokens |
~/.lnget/events.db | Payment event log |
~/.lnget/lnget.log | Application log |
~/.lnget/lnc/sessions/ | Saved LNC sessions |