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

# Searching the Bazaar

> Query the Bazaar from client code, apply filters, paginate, and interpret ranking.

The Bazaar is queryable over HTTP. The client SDK wraps it in `discover()`, but the underlying endpoints are documented in the API reference and are usable from any HTTP client.

## From the SDK

```typescript theme={null}
import { discover } from "@stellarx402/client";

const results = await discover({
  facilitator: "https://facilitator.stellarx402.com",
  query: "weather forecast",
  filters: {
    network: "stellar:pubnet",
    maxPrice: "0.01",
    type: "http",
  },
  sort: "rank",
  limit: 20,
});
```

## Iterating pages

```typescript theme={null}
let cursor: string | undefined;
do {
  const page = await discover({ facilitator, query, cursor });
  for (const r of page.results) handle(r);
  cursor = page.nextCursor;
} while (cursor);
```

## Choosing between search and resources

* Use `discover({ query })` (backed by `/discovery/search`) when you have a natural-language query.
* Use `listResources({ filters })` (backed by `/discovery/resources`) when you have structured filters only.

Both return the same listing shape.

## Interpreting a result

```json theme={null}
{
  "type": "http",
  "resource": "https://api.example.com/weather/{lat}/{lng}",
  "payment": {
    "scheme": "exact",
    "network": "stellar:pubnet",
    "asset": "USDC",
    "amount": "50000"
  },
  "describe": {
    "title": "Weather forecast",
    "description": "5-day hourly forecast",
    "inputs": { "lat": "number", "lng": "number" }
  },
  "signals": { "lastSettled": "...", "settleCount7d": 812 }
}
```

Routes with `{variables}` are templates. Substitute your own values before calling.

## Where next

* [Handling Rejections & Error Codes](/guides/buyers/handling-rejections)
* [Discovery Filters](/discovery/filters)
* [Search & Ranking](/discovery/search-and-ranking)
