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

# MPP quickstart for pay-per-use X API requests

> Make an anonymous pay-per-use tweet, profile, follow-check, article, or trend request with HTTP 402, Tempo USDC, and a payment receipt. See payment examples.

<blockquote className="agent-llms-directive">
  For the complete documentation index, see <a href="/llms.txt">llms.txt</a>.
</blockquote>

Call fixed-price Xquik operations without an account or subscription. Pay per request with Tempo (USDC) using the `mppx` SDK.

## Step 1: install the SDK

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

The `mppx` package provides both client and server utilities. You only need the client. `viem` manages the wallet account.

## Step 2: set up a Tempo wallet

You need a Tempo wallet funded with USDC, plus its raw hex private key for the `mppx` client.

**Path A. CLI only.** Recommended for agents.

```bash theme={null}
mppx account create             # generates a local keychain-backed account
mppx account export             # prints the hex private key (0x...)
```

Fund the account's address with USDC on Tempo, then copy the exported key into `TEMPO_PRIVATE_KEY`.

**Path B. Web wallet as a USDC source.**

Use [wallet.tempo.xyz/welcome](https://wallet.tempo.xyz/welcome) as a hosted UI to buy & send USDC. Run `mppx account create` to create a local account and copy its address. Send USDC from the web wallet to that address. Then run `mppx account export` to get the hex key.

You cannot import the web wallet into `mppx`. It is a funding source, not a key source.

> **Warning.** Never commit your private key to version control. Load it from an environment variable.

## Step 3: make a charge request

Look up a single tweet. The SDK intercepts 402 responses, pays via Tempo, and retries automatically.

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

// Configure the MPP client. This patches global fetch
// to automatically handle 402 Payment Required challenges
Mppx.create({
  methods: [
    tempo({
      account: privateKeyToAccount(process.env.TEMPO_PRIVATE_KEY as `0x${string}`),
    }),
  ],
});

// Now any fetch to an MPP-enabled endpoint auto-pays
const response = await fetch("https://xquik.com/api/v1/x/tweets/1893456789012345678");
const data = await response.json();
console.log(data.tweet.text);
```

`Mppx.create()` patches the global `fetch` function. When a direct MPP request returns 402 with a `WWW-Authenticate: Payment` header, the SDK pays the requested amount and retransmits the request with an `Authorization: Payment` credential. Every response after accepted payment includes a `Payment-Receipt` header confirming settlement.

## Step 4: raw HTTP flow without the SDK

Without the `mppx` SDK, implement the protocol yourself.

**Step 1.** Request the endpoint.

```bash theme={null}
curl -i https://xquik.com/api/v1/x/tweets/1893456789012345678
```

**Step 2.** Receive the 402 challenge.

```text theme={null}
HTTP/2 402
WWW-Authenticate: Payment id="abc...", realm="xquik.com", method="tempo", intent="charge", request="eyJhbW91bnQiOi..."
```

The `request` parameter is a base64url-encoded JSON object containing the amount, currency, and recipient address.

The `application/problem+json` body also includes an optional `payment_options.guest_wallet.create_checkout` action. It does not replace the MPP header. The failed request creates no checkout. Ignore it when completing MPP. Use it only after a user explicitly chooses and confirms a USD 10 to 250 guest wallet.

**Step 3.** Pay and retry.

After completing the Tempo payment, retry the request with the payment credential:

```bash theme={null}
curl -i https://xquik.com/api/v1/x/tweets/1893456789012345678 \
  -H "Authorization: Payment eyJjaGFsbGVuZ2UiOnsi..."
```

The `Authorization: Payment` value is a base64url-encoded JSON object containing the original challenge and your payment proof.

**Step 4.** Receive the response and receipt.

```text theme={null}
HTTP/2 200
Payment-Receipt: eyJzdGF0dXMiOiJzdWNjZXNzIiwi...
Content-Type: application/json

{"tweet": {"id": "1893456789012345678", "text": "..."}}
```

The `Payment-Receipt` header confirms settlement. Check the HTTP status and response body separately because accepted payments also include a receipt on non-2xx responses.

## Next steps

* [MPP overview](/mpp/machine-payments-protocol): direct MPP operations, pricing, and protocol details.
* [Guest wallets](/guides/guest-wallets): Prepay the eligible reads with an accountless API key.
* [Get tweet](/api-reference/x/get-tweet): Full endpoint reference for tweet lookups.
* [Get user](/api-reference/x/twitter-profile-lookup): Full endpoint reference for user lookups.


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