> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eluup.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# x402 Examples

> Complete ELUUP x402 integration example and endpoint request examples.

Copy-ready examples for calling ELUUP's x402 APIs, including a complete TypeScript integration and request-body examples for the other endpoints.

***

## Full Worked Example

```typescript theme={null}
import { wrapAxiosWithPayment, x402Client } from "@x402/axios";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import axios from "axios";
import { privateKeyToAccount } from "viem/accounts";

const signer = privateKeyToAccount(
  process.env.PAYER_PRIVATE_KEY as `0x${string}`,
);
const client = new x402Client();
registerExactEvmScheme(client, { signer });

const api = wrapAxiosWithPayment(
  axios.create({ baseURL: "https://api.eluup.ai" }),
  client,
);

async function getTokenSignals() {
  const response = await api.post("/v1/token-signals", {
    tokens: [{ identifier: "mcade", limit: 10 }],
  });

  if (response.status >= 200 && response.status < 300) {
    console.log("Results:", response.data.data.results);
    return response.data.data.results;
  }

  if (response.status === 402) {
    const decoded = JSON.parse(
      Buffer.from(response.headers["payment-required"], "base64").toString(
        "utf-8",
      ),
    );
    console.error("Payment failed:", decoded.error);
    return null;
  }

  console.error("Request failed:", response.data?.error);
  return null;
}

getTokenSignals();
```

***

## Other endpoint examples (request bodies only)

**Token Prices** — 2 tokens, expected payment `2 × $0.03 = $0.06`:

```json theme={null}
{ "tokens": [{ "identifier": "ETH" }, { "identifier": "USDC" }] }
```

**Signal History** with a date range:

```json theme={null}
{
  "tokens": [{ "identifier": "clanker" }],
  "startDate": "2026-01-01T00:00:00Z",
  "endDate": "2026-03-31T23:59:59Z",
  "signalType": "SELL"
}
```

**Top Performers** — fixed `$0.06`:

```json theme={null}
{ "sortBy": "winRate", "limit": 10 }
```

**Aggregate Metrics** — fixed `$0.06`, empty body:

```json theme={null}
{}
```

**Supported Tokens** — free, no payment header needed:

```json theme={null}
{ "limit": 100 }
```

***

**x402 docs:** [Overview](/x402) · [Quickstart](/x402/quickstart) · [Payment Flow](/x402/payment-flow) · [API Reference](/x402/api-reference) · [Errors & Troubleshooting](/x402/errors) · [Examples](/x402/examples)
