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

# Pay per request with MPP

> Call DexPaprika endpoints without an API key by paying per request in USDC on Tempo with the Machine Payments Protocol. Read the 402 challenge, pay from the Tempo CLI, or pay from TypeScript with mppx and a spending cap.

`mpp.dexpaprika.com` serves the DexPaprika REST endpoints for a payment per request, in USDC on [Tempo](https://tempo.xyz), with the [Machine Payments Protocol](https://mpp.dev) (MPP). There is no API key, account or signup: the endpoint answers your first request with HTTP `402 Payment Required`, your client pays, sends the request again with the payment credential, and gets the data.

It is built for AI agents and scripts that hold a wallet and call now and then, and for reaching endpoints that need a paid plan on the REST API, such as [token OHLCV](https://docs.dexpaprika.com/tutorials/token-ohlcv.md), [token indicators](https://docs.dexpaprika.com/tutorials/technical-indicators.md) and [pool transactions](https://docs.dexpaprika.com/tutorials/pool-transactions.md), without a subscription. If you call DexPaprika every day, a [free API key](https://console.dexpaprika.com) or a [plan](https://dexpaprika.com/api/pricing) fits better. To pay with USDC on Base instead, see [x402](https://docs.dexpaprika.com/ai-integration/x402.md).

## What you need

* A Tempo wallet holding USDC. On Tempo it is the `USDC.e` token, `0x20C000000000000000000000b9537d11c60E8b50`. Tempo has no separate gas token: the network fee is paid in the same stablecoin, so keep a little more than the price.
* The [Tempo CLI](https://docs.tempo.xyz), or Node.js 18 or later for the TypeScript example.

> [!WARNING]
>
> Use a separate wallet that holds only what you are willing to spend, and set a spending cap in your client. Both examples below set one.

## Endpoints and price

The paths, parameters and JSON responses are the same as on `api.dexpaprika.com`, so every [tutorial](https://docs.dexpaprika.com/tutorials/tutorial_intro.md) and the [API reference](https://docs.dexpaprika.com/api-reference/introduction.md) apply. Swap the host and the payment replaces the key.

> [accordion] Paid endpoints
>
> * `GET /networks`
> * `GET /search`
> * `GET /stats`
> * `GET /pools/search`
> * `GET /tokens/search`
> * `GET /networks/{network}/dexes`
> * `GET /networks/{network}/multi/prices`
> * `GET /networks/{network}/pools/search`
> * `GET /networks/{network}/pools/{pool_address}`
> * `GET /networks/{network}/pools/{pool_address}/ohlcv`
> * `GET /networks/{network}/pools/{pool_address}/transactions`
> * `GET /networks/{network}/pools/{pool_address}/indicators`
> * `GET /networks/{network}/tokens/search`
> * `GET /networks/{network}/tokens/{token_address}`
> * `GET /networks/{network}/tokens/{token_address}/ohlcv`
> * `GET /networks/{network}/tokens/{token_address}/indicators`

Every 402 states its own price. The current price list is on [mpp.dexpaprika.com](https://mpp.dexpaprika.com), and agents can read it from:

* [`/openapi.json`](https://mpp.dexpaprika.com/openapi.json): the OpenAPI spec with an `x-payment-info` offer on every operation
* [`/.well-known/agent-payments`](https://mpp.dexpaprika.com/.well-known/agent-payments): price, asset and network per endpoint

## Step 1: read the challenge

The payment terms come back in the `WWW-Authenticate` header, with the scheme name `Payment`:

```bash theme={null}
curl -s -D - -o /dev/null \
  "https://mpp.dexpaprika.com/networks/solana/tokens/So11111111111111111111111111111111111111112" \
  | grep -i '^www-authenticate:'
```

```text theme={null}
www-authenticate: Payment id="uVVMkIDGOrlJpVuq8dvid3Z9G6vJSvmB4_BPqz5qW1U", realm="mpp.dexpaprika.com", method="tempo", intent="charge", request="eyJhbW91bnQiOiI1MDAw...", expires="..."
```

`method="tempo"` and `intent="charge"` mean a one-off payment on Tempo. The `request` parameter is base64url-encoded JSON with the terms:

```json theme={null}
{
  "amount": "5000",
  "currency": "0x20C000000000000000000000b9537d11c60E8b50",
  "methodDetails": { "chainId": 4217 },
  "recipient": "0x7eA2dCB09b3eBCFb9Ee1195C9587f944d8067Bc9"
}
```

| Field | Meaning |
| - | - |
| `amount` | The price in base units. The token has 6 decimals, so `5000` is 0.005 USDC |
| `currency` | The USDC token on Tempo |
| `methodDetails.chainId` | `4217` is Tempo mainnet |
| `recipient` | The DexPaprika address that receives the payment |

The Tempo CLI decodes all of this for you without paying:

```bash theme={null}
tempo request --dry-run \
  "https://mpp.dexpaprika.com/networks/solana/tokens/So11111111111111111111111111111111111111112"
```

```json theme={null}
{
  "payment_required": true,
  "method": "tempo",
  "intent": "charge",
  "amount": "0.005",
  "raw_amount": "5000",
  "token": "0x20c000000000000000000000b9537d11c60e8b50",
  "symbol": "USDC.e",
  "decimals": 6,
  ...
}
```

## Step 2: pay from the command line

Install the Tempo CLI and connect a wallet:

```bash theme={null}
curl -fsSL https://tempo.xyz/install | bash
tempo wallet login
```

Then request the endpoint. The CLI pays the challenge and prints the response body. `--max-spend` caps what this command may spend, in USDC:

```bash theme={null}
tempo request --max-spend 0.01 \
  "https://mpp.dexpaprika.com/networks/solana/tokens/So11111111111111111111111111111111111111112"
```

```json theme={null}
{"id":"So11111111111111111111111111111111111111112","name":"Wrapped SOL","symbol":"SOL","chain":"solana","decimals":9,...}
```

To pay from a specific key instead of the logged-in wallet, set `TEMPO_PRIVATE_KEY` in the environment.

## Step 3: pay from TypeScript

Install [mppx](https://mpp.dev) and viem:

```bash theme={null}
npm install mppx viem
```

Save this as `pay.mjs`:

```javascript theme={null}
import { Mppx, tempo } from "mppx/client";
import { Receipt } from "mppx";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const USDC = "0x20C000000000000000000000b9537d11c60E8b50";

const mppx = Mppx.create({
  // Pay only in USDC, and never more than 1 cent per request.
  methods: [tempo({ account, currencies: [USDC], decimals: 6, maxAmount: "0.01" })],
  polyfill: false,
});

const url =
  "https://mpp.dexpaprika.com/networks/solana/tokens/So11111111111111111111111111111111111111112";
const res = await mppx.fetch(url);
const data = await res.json();
console.log(res.status, data.symbol, data.summary?.price_usd);
console.log(Receipt.fromResponse(res));
```

Run it with the wallet's private key in the environment:

```bash theme={null}
PRIVATE_KEY=0xYOUR_PRIVATE_KEY node pay.mjs
```

```text theme={null}
200 SOL 70.86707294903304
{
  fundingCurrency: '0x20C000000000000000000000b9537d11c60E8b50',
  method: 'tempo',
  reference: '0x57f42d45ea1e84616b00d01c794d2e8ad2d008adaea7cb959681dbca3d97aeab',
  status: 'success',
  timestamp: '2026-11-26T08:42:26.286Z'
}
```

`mppx.fetch` makes the first request, reads the 402, pays and retries. The receipt comes from the `Payment-Receipt` header: `reference` is the payment transaction, which you can look up on the [Tempo explorer](https://explore.tempo.xyz).

`maxAmount` is the safety net. A challenge above it is skipped and the call throws without paying. `polyfill: false` keeps `mppx` from replacing the global `fetch`; leave it out if you want every `fetch` in your process to pay automatically.

## Errors you don't pay for

A request with a bad parameter or for something that doesn't exist is refused before the payment challenge, so your client never pays for it.

A parameter value that isn't allowed gets `400`:

```json theme={null}
{"error":"invalid_param","message":"invalid query param: interval (must be one of [1m 5m 10m 15m 30m 1h 6h 12h 24h])","param":"interval"}
```

An unknown network, token or pool gets `404`:

```json theme={null}
{"type":"https://dexpaprika.com/problems/upstream-not-found","title":"Upstream Not Found","status":404,"code":"upstream_not_found","detail":"upstream returned 404 for the requested resource","instance":"/networks/solana/tokens/NotARealTokenAddress1111111111111111111111","upstream_status":404}
```

The allowed values for each parameter are in the [API reference](https://docs.dexpaprika.com/api-reference/introduction.md).

## Next steps

> [card] [Pay with x402 on Base](https://docs.dexpaprika.com/ai-integration/x402.md)
>
> The same endpoints, paid in USDC on Base with the x402 protocol.

> [card] [Get an API key](https://console.dexpaprika.com)
>
> For daily use, a free key in the DexPaprika console, with plans on the [pricing page](https://dexpaprika.com/api/pricing).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.