Skip to content

Account & billing

NWC auto top-up

Connect a Nostr Wallet Connect (NWC) Lightning wallet to top up your balance automatically when it falls below a threshold. The wallet must support the pay_invoice capability. Compatible wallets include Alby Hub, LNBits, Primal and others.

Every endpoint on this page needs your credit ID in the x-credit-id header.

Base URL

https://api.ppq.ai

POST /nwc-auto-topup/connect

Connect an NWC wallet for automatic top-ups.

Request body

ParameterTypeRequiredDescription
nwc_url
string
Yes
Your NWC connection string.
threshold_usd
number
No
A top-up starts when your balance falls below this amount, in USD. Default: 10. Minimum: 5.
topup_amount_usd
number
No
Amount to top up each time, in USD. Default: 10.

Example

import requests

credit_id = "YOUR_CREDIT_ID"
url = "https://api.ppq.ai/nwc-auto-topup/connect"

headers = {
    "Content-Type": "application/json",
    "x-credit-id": credit_id
}

data = {
    "nwc_url": "nostr+walletconnect://your-wallet-pubkey?relay=wss://relay.example.com&secret=your-secret",
    "threshold_usd": 5,
    "topup_amount_usd": 10
}

response = requests.post(url, json=data, headers=headers)
print(response.json())

GET /nwc-auto-topup

Get your current NWC auto top-up settings.

Example

import requests

credit_id = "YOUR_CREDIT_ID"
url = "https://api.ppq.ai/nwc-auto-topup"

headers = {
    "x-credit-id": credit_id
}

response = requests.get(url, headers=headers)
print(response.json())

POST /nwc-auto-topup/resume

Resume auto top-up after a failed payment paused it (wallet out of funds, or its spending budget exceeded). The call re-validates the stored wallet connection, turns auto top-up back on and, if your balance is below the threshold, attempts a top-up straight away.

Response

FieldTypeDescription
enabled
boolean
Whether auto top-up is active after the attempt.
charged
boolean
Whether a top-up was paid during this call.
disabled_reason
string | null
Set when the retry failed again. One of insufficient_balance, quota_exceeded, connection_revoked.
failure_reason
string | null
Set when a top-up was attempted in this call and failed. null when no charge was needed or the top-up succeeded.
balance_sats_before_charge
integer
Wallet balance in sats reported while checking the connection, before any top-up paid in this call.

Returns 400 if the wallet no longer accepts the stored connection (reconnect with POST /nwc-auto-topup/connect) and 404 if no wallet is connected.

Example

import requests

credit_id = "YOUR_CREDIT_ID"
url = "https://api.ppq.ai/nwc-auto-topup/resume"

headers = {
    "x-credit-id": credit_id
}

response = requests.post(url, headers=headers)
print(response.json())

DELETE /nwc-auto-topup/connection

Disconnect your NWC wallet and turn off auto top-up.

Example

import requests

credit_id = "YOUR_CREDIT_ID"
url = "https://api.ppq.ai/nwc-auto-topup/connection"

headers = {
    "x-credit-id": credit_id
}

response = requests.delete(url, headers=headers)
print(response.json())