# Read listings

> Search a marketplace with the browse filters, page by page.


`GET /listings` answers what a browse page on the site shows, with the same filters and in the same order: nearest first when you send a `zip`, newest first without one.

```bash cURL
curl -H "Authorization: Bearer ssk_YOUR_KEY" "https://dev.siteswap.pro/api/v1/listings?marketplace=materials&q=rebar&zip=01801&radius=50"
```
```javascript JavaScript
const url = new URL("https://dev.siteswap.pro/api/v1/listings");
url.search = new URLSearchParams({ marketplace: "materials", q: "rebar", zip: "01801", radius: "50" });
let cursor = null;
do {
  if (cursor) url.searchParams.set("cursor", cursor);
  const res = await fetch(url, { headers: { Authorization: "Bearer " + process.env.SITESWAP_KEY } });
  const page = await res.json();
  for (const l of page.data) console.log(l.id, l.title, l.location.distance_mi);
  cursor = page.next_cursor;
} while (cursor);
```
```python Python
import os, requests
params = {"marketplace": "materials", "q": "rebar", "zip": "01801", "radius": "50"}
headers = {"Authorization": "Bearer " + os.environ["SITESWAP_KEY"]}
while True:
    page = requests.get("https://dev.siteswap.pro/api/v1/listings", params=params, headers=headers).json()
    for l in page["data"]:
        print(l["id"], l["title"])
    if not page["next_cursor"]:
        break
    params["cursor"] = page["next_cursor"]
```

## Filters

| Filter | What it does |
|---|---|
| `marketplace` | Which marketplace. `GET /marketplaces` lists the open ones. |
| `q` | Words, matched like the search box: titles, materials, brands, regional names. |
| `zip`, `radius` | Distance from a ZIP, and only within 25, 50 or 100 miles. |
| `kind`, `deal` | Offered or wanted; for sale, for trade or both. |
| `category`, `material` | A category slug, then materials or types of it. |
| `brand`, `line`, `color`, `model`, `platform` | Catalog picks, by id. |
| `price`, `delivers`, `pickup`, `loading`, `ships` | The quick filters of the browse page. |
| `company` | One company's live listings, by its slug. |

A filter the marketplace does not have is left out, as on the site. A closed marketplace answers `404 marketplace_closed`.

## One listing

`GET /listings/{id}` answers a live listing, or your own company's listing in any state. Add `zip` to get its distance.
