Skip to main content

Quickstart Guide

Get started with HTTPayer in under 5 minutes.

Proxy Endpoint

Prerequisites

  • A HTTPayer API key (contact the team to get one)

Step 1: Get Your API Key and Set Up Your Environment

Contact the HTTPayer team to receive your API key. You’ll use this in the X-API-KEY header for all requests.

Step 2: Make a Simulation Request

Test the payment flow without executing a transaction. Typescript:
const HTTPAYER_API_KEY = process.env.HTTPAYER_API_KEY;

if (!HTTPAYER_API_KEY) {
  throw new Error("HTTPAYER_API_KEY is not set");
}

const TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto";

const payload = {
  api_url: TARGET_API,
  method: "GET",
};

const response = await fetch("https://api.httpayer.com/proxy/sim", {
  method: "POST",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
    "X-API-KEY": HTTPAYER_API_KEY
  },
  body: JSON.stringify(payload),
});

const data = await response.json();

console.log(JSON.stringify(data, null, 2));
Python:
import requests
import json

TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto"

session = requests.Session()

payload = {
  "api_url": TARGET_API,
  "method": "GET",
}
headers = {"X-API-KEY": HTTPAYER_API_KEY, "Content-Type": "application/json"}

response = session.post("https://api.httpayer.com/proxy/sim", headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))
Response:
{
  "dryRun": true,
  "paymentInstructions": {
    "scheme": "exact",
    "network": "base",
    "maxAmountRequired": "30000",
    "resource": "https://api.itsgloria.ai/news",
    "description": "Get the latest news about a covered news topic, delivering the most recent 10 headlines.",
    "mimeType": "application/json",
    "payTo": "0xCa1271E777C209e171826A681855351f4989cd0c",
    "maxTimeoutSeconds": 60,
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  }
}

Step 3: Make a Payment-Gated Request

Execute the full payment + request flow using the /proxy endpoint. Typescript:
const HTTPAYER_API_KEY = process.env.HTTPAYER_API_KEY;

if (!HTTPAYER_API_KEY) {
  throw new Error("HTTPAYER_API_KEY is not set");
}

const TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto";

const payload = {
  api_url: TARGET_API,
  method: "GET",
};

const response = await fetch("https://api.httpayer.com/proxy", {
  method: "POST",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
    "X-API-KEY": HTTPAYER_API_KEY
  },
  body: JSON.stringify(payload),
});

const data = await response.json();
const respBody = data.body;

console.log(JSON.stringify(respBody, null, 2));
Python:
import requests
import json

HTTPAYER_API_KEY = os.getenv("HTTPAYER_API_KEY")

TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto"

session = requests.Session()

payload = {
  "api_url": TARGET_API,
  "method": "GET",
}
headers = {"X-API-KEY": HTTPAYER_API_KEY, "Content-Type": "application/json"}

response = session.post("https://api.httpayer.com/proxy", headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))

Relay Endpoint

Prerequisites

  • USDC on Base, Base Sepolia, Solana, or Solana Devnet
  • A HTTP client configured with x402 payment abilities (x402-fetch on Typescript, x402 on Python)

Step 1: Create a Wallet Client

Typescript:
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { wrapFetchWithPayment } from "x402-fetch";
import { baseSepolia } from "viem/chains";

// Create a wallet client
const account = privateKeyToAccount("0xYourPrivateKey");
const client = createWalletClient({
  account,
  transport: http(),
  chain: baseSepolia,
});

// Wrap the fetch function with payment handling
const fetchWithPay = wrapFetchWithPayment(fetch, client);
Python:
import json
from eth_account import Account
from x402.clients.requests import x402_requests

# Initialize account
account = Account.from_key("your_private_key")

# Create session and make request
session = x402_requests(account)

Step 2: Make a Simulation Request

Test the payment flow without executing a transaction. Typescript:
const TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto";

const payload = {
  api_url: TARGET_API,
  method: "GET",
  network: "base"
}

const response = await fetchWithPay("https://api.httpayer.com/relay/sim", {
  method: "POST",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});

const data = await response.json();

console.log(JSON.stringify(data, null, 2));
Python:
TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto"

payload = {
  "api_url": TARGET_API,
  "method": "GET",
  "network": "base"
}
headers = {"Content-Type": "application/json"}

response = session.post("https://api.httpayer.com/relay/sim", headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))
Response:
{
  "requiresPayment": true,
  "targetPaymentRequirements": {
    "scheme": "exact",
    "network": "base",
    "maxAmountRequired": "30000",
    "resource": "https://api.itsgloria.ai/news",
    "description": "Get the latest news about
a covered news topic, delivering the most recent 10 headlines.",
    "mimeType": "application/json",
    "payTo": "0xCa1271E777C209e171826A681855351f4989cd0c",
    "maxTimeoutSeconds": 60,
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
  }
}

Step 3: Make a Payment-Gated Request

Execute the full payment + request flow using the /relay endpoint. Typescript:
const TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto";

const payload = {
  api_url: TARGET_API,
  method: "GET",
  network: "base"
}

const response = await fetchWithPay("https://api.httpayer.com/relay", {
  method: "POST",
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});

const data = await response.json();
const respBody = data.body;

console.log(JSON.stringify(respBody, null, 2));
Python:
TARGET_API = "https://api.itsgloria.ai/news?feed_categories=ai,crypto"

payload = {
  "api_url": TARGET_API,
  "method": "GET",
  "network": "base"
}
headers = {"Content-Type": "application/json"}

response = session.post("https://api.httpayer.com/relay", headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))

Next Steps

Support

Need help? Reach out to the HTTPayer team or check out our GitHub repository.