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

# Consuming a Marketplace

> Discover paid APIs from a marketplace registry and call them from any wallet.

The client side of a marketplace is intentionally thin: a discovery service tells you what APIs exist and what they cost; [`@faremeter/rides`](/client/rides-sdk) handles payment when you call them. There are no accounts, no API keys, and no per-marketplace SDKs.

## The shape of every marketplace API

Regardless of which marketplace operator you talk to, every published API looks the same to you:

* **A proxy URL.** Where your HTTP requests go. Returned by the marketplace's discovery service.
* **An OpenAPI spec.** Tells you what endpoints exist, what they accept, and (via `x-faremeter-pricing` extensions) what they cost.
* **A 402 challenge.** When you call a paid endpoint without payment, the proxy responds with `402 Payment Required` and the requirements for paying. `@faremeter/rides` handles this for you.

## The flow

<Steps>
  <Step title="Discover">
    Query the operator's discovery service for APIs by name, tag, or capability. Pick the one you want and read its OpenAPI spec to see the endpoints and pricing.
  </Step>

  <Step title="Fund a wallet">
    Any wallet supported by [`@faremeter/rides`](/client/rides-sdk) works — keypair file, Crossmint, Squads, Ledger. Fund it with the asset the API charges in (typically USDC on Solana or an EVM chain).
  </Step>

  <Step title="Call and pay">
    Make the HTTP request. `rides` reads the 402, signs payment locally, retries, and gives you back the response. You never touch the payment headers yourself.
  </Step>
</Steps>

## Calling a marketplace API

If you already know the proxy URL, this is the entire client:

```typescript theme={null}
import { payer } from "@faremeter/rides";

await payer.addLocalWallet(process.env.PAYER_KEYPAIR_PATH);
const res = await payer.fetch("https://example-tenant.example-marketplace.dev/v1/quote");
const data = await res.json();
```

The `payer.fetch` call:

1. Sends the request.
2. Sees `402 Payment Required` with the marketplace's payment requirements.
3. Signs a payment with your wallet.
4. Retries the request with the payment header.
5. Returns the response when the marketplace settles and the publisher's backend replies.

For wallet options and configuration, see [Wallet setup](/client/wallet-setup) and [Wallet configuration](/client/wallet-configuration).

## Discovering APIs

The Discovery API is a public, unauthenticated REST API. The hosted Corbits instance is at `https://api.corbits.dev`; a self-hosted marketplace exposes its own URL.

```bash theme={null}
# Search for APIs by keyword
curl "https://api.corbits.dev/api/v1/search?q=openai"

# List all proxies
curl "https://api.corbits.dev/api/v1/proxies"

# Get a proxy's full OpenAPI spec
curl "https://api.corbits.dev/api/v1/proxies/61/openapi"
```

Typical response shape (truncated):

```json theme={null}
{
  "data": {
    "proxies": [
      {
        "id": 61,
        "name": "open-ai",
        "url": "https://openai.api.corbits.dev",
        "default_price_usdc": 10000,
        "default_scheme": "exact"
      }
    ]
  }
}
```

Use the `url` field as the base for your `payer.fetch` calls. Prices are integers in **micro-USDC** — `10000` means `$0.01`.

For the full Discovery API surface (search, listing, OpenAPI spec retrieval, pagination), see the [Corbits Discovery API reference](https://docs.corbits.dev/discovery/discovery-api). A self-hosted marketplace running the same OSS code exposes the same endpoints.

## Agent-friendly

Because there are no accounts and no API keys, an AI agent can do everything above autonomously: search the catalog, pick an API, sign payments from its own wallet, and consume the response. This is the same pattern the [AI agent payments recipe](/recipes/ai-agent-payments) describes — the marketplace just gives the agent a directory to discover APIs in.

## What's next

<CardGroup cols={2}>
  <Card title="Rides SDK" icon="bolt" href="/client/rides-sdk">
    The minimal client for paying any x402-protected URL.
  </Card>

  <Card title="Wallet setup" icon="wallet" href="/client/wallet-setup">
    Pick a wallet adapter and fund it.
  </Card>

  <Card title="Payment Schemes" icon="coins" href="/concepts/payment-schemes">
    Understand `exact`, `charge`, and `flex` charges you'll see in the wild.
  </Card>

  <Card title="AI Agent Payments" icon="robot" href="/recipes/ai-agent-payments">
    Recipe for autonomous discovery + payment.
  </Card>
</CardGroup>
