| name | lnget |
| description | Install and use lnget, a Lightning-native HTTP client with automatic L402 payment support. Use when downloading files behind Lightning paywalls, managing L402 tokens, checking Lightning backend status, or making HTTP requests that may require micropayments. |
lnget - Lightning-Native HTTP Client
lnget is a wget/curl-like CLI that natively handles L402 (Lightning HTTP 402)
authentication. When a server responds with HTTP 402 and an L402 challenge,
lnget automatically pays the Lightning invoice and retries with the paid token.
Source: github.com/lightninglabs/lnget
Quick Start
skills/lnget/scripts/install.sh
lnget config init
lnget --max-cost 1000 https://api.example.com/paid-data
Installation
skills/lnget/scripts/install.sh
This will:
- Verify Go is installed
- Run
go install github.com/lightninglabs/lnget/cmd/lnget@latest
- Verify
lnget is on $PATH
To install manually:
go install github.com/lightninglabs/lnget/cmd/lnget@latest
Or build from source:
git clone https://github.com/lightninglabs/lnget.git
cd lnget
make install
Basic Usage
Downloads
lnget https://api.example.com/data.json
lnget -o data.json https://api.example.com/data.json
lnget -q https://api.example.com/data.json | jq .
lnget -c -o largefile.zip https://api.example.com/largefile.zip
lnget -X POST -d '{"query":"test"}' https://api.example.com/search
lnget -H "Accept: text/plain" https://api.example.com/data
Payment Control
lnget --max-cost 5000 https://api.example.com/expensive.json
lnget --max-fee 50 https://api.example.com/data.json
lnget --no-pay https://api.example.com/data.json
lnget --payment-timeout 120s https://api.example.com/data.json
Output Modes
lnget --json https://api.example.com/data.json
lnget --human https://api.example.com/data.json
lnget -v https://api.example.com/data.json
lnget --no-progress -o file.zip https://api.example.com/file.zip
Subcommands
Token Management (lnget tokens)
Tokens are cached per-domain at ~/.lnget/tokens/<domain>/token.json and
reused automatically on subsequent requests.
lnget tokens list
lnget tokens show api.example.com
lnget tokens remove api.example.com
lnget tokens clear --force
Configuration (lnget config)
lnget config init
lnget config show
lnget config path
Lightning Backend (lnget ln)
lnget ln status
lnget ln info
LNC (Lightning Node Connect)
lnget ln lnc pair "your-pairing-phrase"
lnget ln lnc pair "phrase" --ephemeral
lnget ln lnc sessions
lnget ln lnc revoke <session-id>
Neutrino (Embedded Wallet)
lnget ln neutrino init
lnget ln neutrino fund
lnget ln neutrino balance
lnget ln neutrino status
Configuration File
Config lives at ~/.lnget/config.yaml. Run lnget config init to create it.
Note: lnget config init may generate incorrect YAML key names (e.g.,
tlscertpath and macaroonpath instead of tls_cert and macaroon) due to
missing yaml struct tags in the lnget source. Use the example below as the
reference config format. If your config was generated by lnget config init,
verify the ln.lnd keys match the format shown here.
l402:
max_cost_sats: 1000
max_fee_sats: 10
payment_timeout: 60s
auto_pay: true
http:
timeout: 30s
max_redirects: 10
user_agent: "lnget/0.1.0"
allow_insecure: false
ln:
mode: lnd
lnd:
host: localhost:10009
tls_cert: ~/.lnd/tls.cert
macaroon: ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
network: mainnet
output:
format: json
progress: true
verbose: false
tokens:
dir: ~/.lnget/tokens
Environment variables override config with LNGET_ prefix:
export LNGET_L402_MAX_COST_SATS=5000
export LNGET_LN_MODE=lnc
export LNGET_LN_LND_HOST=localhost:10009
Exit Codes
| Code | Meaning |
|---|
| 0 | Success |
| 1 | General error |
| 2 | Payment exceeds max cost |
| 3 | Payment failed |
| 4 | Network/connection error |
L402 Flow
When lnget encounters a 402 response:
- Parses
WWW-Authenticate: L402 macaroon="...", invoice="..." header
- Decodes the macaroon and BOLT11 invoice
- Checks invoice amount against
--max-cost
- Stores a pending token (crash recovery)
- Pays the invoice via the configured Lightning backend
- Stores the paid token with preimage at
~/.lnget/tokens/<domain>/
- Retries the request with
Authorization: L402 <macaroon>:<preimage>
Subsequent requests to the same domain reuse the cached token without payment.
Agent Integration Patterns
Budget-Aware Fetching
result=$(lnget --no-pay --json https://api.example.com/data.json)
cost=$(echo "$result" | jq -r '.invoice_amount_sat // 0')
if [ "$cost" -le "$BUDGET" ]; then
lnget --max-cost "$BUDGET" -q https://api.example.com/data.json
fi
Parsing JSON Output
lnget --json -q https://api.example.com/data.json | jq '.body'
lnget --json https://api.example.com/data.json | jq '.l402_paid'
Testing with Insecure Connections
lnget -k https://localhost:8081/api/data
File Locations
| Path | Purpose |
|---|
~/.lnget/config.yaml | Configuration file |
~/.lnget/tokens/<domain>/ | Per-domain token storage |
~/.lnget/lnc/sessions/ | LNC session persistence |
~/.lnget/neutrino/ | Embedded wallet data |