Provider Setup (One-Time)

Steps:

  • Connect Solana wallet.

  • Create project in Qwery dashboard.

  • Define:

    • base URL

    • endpoints + price per call

    • optional free tier

  • Install SDK and wrap endpoints.

As a merchant/developer integrating payments:

  1. Get facilitator URL: https://facilitator.qwery.xyz

  2. Install SDK:

# TypeScript
npm install @qwerydotxyz/qwery-sdk

# Python
pip install qwery-sdk

# Rust
cargo add qwery-sdk
  1. Configure:

FACILITATOR_URL=https://facilitator.qwery.xyz
MERCHANT_WALLET=your_solana_wallet_address
NETWORK=solana  # or solana-devnet for testing
  1. Initialize:

import { QweryPayment } from '@qwerydotxyz/qwery-sdk';

const qwery = new QweryPayment({
  facilitatorUrl: process.env.FACILITATOR_URL,
  network: process.env.NETWORK
});
  1. Test on devnet before production

TypeScript / Express

npm install @qwery/sdk
import express from 'express';
import { qwery } from '@qwery/sdk';

const app = express();
app.use(express.json());

app.use(
  qwery({
    secretKey: process.env.QWERY_SECRET_KEY,
    environment: 'production',
  })
);

app.post(
  '/api/sentiment',
  qwery.paid(0.05), // 0.05 USDC per call
  async (req, res) => {
    const result = await analyzeSentiment(req.body.text);
    res.json(result);
  }
);

app.listen(3000);

FastAPI

pip install qwery-payments
from fastapi import FastAPI
from qwery_payments import QweryMiddleware, paid

app = FastAPI()

app.add_middleware(
    QweryMiddleware,
    secret_key="QWERY_sk_live_...",
    environment="production",
)

@app.post("/api/sentiment")
@paid(0.05)
async def analyze_sentiment(text: str):
    result = perform_analysis(text)
    return {"sentiment": result.sentiment, "score": result.score}

Next.js Routets

// app/api/analyze/route.ts
import { NextRequest } from 'next/server';
import { qwery } from '@qwery/sdk';

export const POST = qwery.nextjs({
  secretKey: process.env.QWERY_SECRET_KEY!,
  price: 0.05,
  handler: async (req: NextRequest) => {
    const { text } = await req.json();
    const result = await analyzeSentiment(text);
    return Response.json(result);
  },
});

Last updated