Skip to content

Monetising APIs

Any HTTPS or WebSocket API can be monetised through Dhali.

There are two main ways to integrate:

  1. Reverse Proxy (easiest)
  2. Direct Charging (more control)

Requirements

Integration Model What You’ll Need
Reverse Proxy - HTTPS or WebSocket base URL
- Header secret for authenticating requests forwarded by Dhali
- An XRP Ledger or Xahau wallet
Direct Charging - An XRP Ledger or Xahau wallet

Monetising your API

  1. Go to the API Portal: Open API Portal →
  2. Link your wallet: Authenticate using your preferred wallet.
  3. Create a new API: Navigate to My AssetsCreate.
  4. Configure your API:
  5. A template API will appear on your My Assets page.
  6. Click it, then select Edit to configure details such as name, base URL, and pricing.
  7. Choose your Integration Model:
    After saving, your API page will display your endpoint URL.
    Select one of the following:

Dhali acts as a reverse proxy, verifying payments before forwarding requests to your API.
No code changes are required.

Your users should call:

https://run.api.dhali.io/<your_api_uuid>

Dhali validates the payment and forwards the request to your server securely.

Your API directly handles payment verification.

Workflow:

  1. Your users send requests directly to your API.
  2. Your API extracts the Payment-Claim header.
  3. It then makes a POST request to:
    https://charge.api.dhali.io/<your_api_uuid>
    
    Body:
    { "paymentHeader": "<payment-claim-header>" }
    
  4. Fulfill the request only if Dhali responds with:
    { "isValid": true }
    

For a real-world example, see our blog post on building a GPT that pays for an XRP API with nano-payments.