Monetising APIs
Any HTTPS or WebSocket API can be monetised through Dhali.
There are two main ways to integrate:
- Reverse Proxy (easiest)
- 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
- Go to the API Portal: Open API Portal →
- Link your wallet: Authenticate using your preferred wallet.
- Create a new API: Navigate to My Assets → Create.
- Configure your API:
- A template API will appear on your My Assets page.
- Click it, then select Edit to configure details such as name, base URL, and pricing.
- 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:
- Your users send requests directly to your API.
- Your API extracts the
Payment-Claim
header. - It then makes a
POST
request to:Body:https://charge.api.dhali.io/<your_api_uuid>
{ "paymentHeader": "<payment-claim-header>" }
- 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.