# CoStar extraction reference

CoStar's product UI lives at `product.costar.com`. The tabs we care about for a space report:

| Tab        | URL pattern                                       | What it gives us                                          |
|------------|---------------------------------------------------|-----------------------------------------------------------|
| Summary    | `/detail/lookup/{id}/summary`                     | Building specs, Space table, Documents links              |
| Lease      | `/detail/lookup/{id}/lease`                       | Per-suite detail (richer when listings are publicly fed)  |
| Images     | `/detail/lookup/{id}/images`                      | Building Photo, Aerial, Plat Map, Floor Plan thumbnails   |

The user is responsible for being logged in. The MCP tab group must include the CoStar tab — if it doesn't, ask them to drag it in (it can't navigate cookies for them).

## Summary tab — building fields

The summary header has the headline data in plain `<generic>` regions with no stable test IDs. Walk by label text. Fields you'll need (see the actual labels on the page next to each value):

- Address: `260 Townsend St` (top H1 region)
- Submarket subline: `Office - South of Market Submarket`
- City/State/Zip: `San Francisco, CA 94107`
- `SF RBA` — total rentable building area
- `AC Lot` — lot acreage
- `Built` — year
- `Available SF` — range of currently available SF, e.g. `2,646 - 53,498`
- `Max Contig SF` — largest contiguous block

The "Building" detail block below the header has additional specs you may quote in the description blurb: Type (e.g. `3 Star Office`), Stories, Typical Floor, Class, Construction (Steel / Brick & Timber matters — drives the example's "exposed brick-and-timber" language), Slab to Slab, Sprinklers.

## Summary tab — Space table

This is the most important table on the page. Each row has a "P" or "E" prefix on the floor:

- `P 2nd` → Partial floor (suite available on the 2nd floor; the floor is not entirely available)
- `E 5th` → Entire 5th floor

For the report, you usually map both to a clean label like `2nd Floor` or `5th Floor`. If multiple suites on one floor, the brochure or the per-suite page will distinguish them.

Columns: Floor · Available SF · Use · Rent · Services. `Rent: Withheld` should map to `TBD` in the matrix; otherwise CoStar shows a per-SF figure with a service type suffix (`/FS` = full-service, `/NNN` = triple-net). Compute monthly cost = `rate × available_sf` only when the rate is disclosed.

## Summary tab — Documents section

Scroll down the summary page; near the bottom is a `Documents` block with a `Property` heading and one or more PDF link icons. Each link's `<label>` text is the brochure's filename stem (e.g. `Townsend_260`). The `href` is a direct CDN URL to the PDF: `https://ahprd1cdn.csgpimgs.com/d2/{hash}/{filename}.pdf`. These URLs are session-authenticated; download them through the browser session, not via raw `requests`.

## Images tab — CDN pattern

`<img>` elements have stable `alt` attributes that classify each image:

- `Primary Photo`
- `Building Photo` (often multiple)
- `Aerial`
- `Plat Map`
- `Floor Plan` (often multiple per building)

URL pattern: `https://ahprd1cdn.csgpimgs.com/i2/{hash}/118/image.jpg`. The `/118/` segment is a size token; CoStar serves higher-resolution variants at `/200/`, `/416/`, `/818/`. For the deck, prefer `/416/` or `/818/` for sharpness; fall back to `/118/` if the larger size 404s. Always download in-session as a blob (the CDN gates by cookie).

Floor plans on the Images tab are often building-level plans showing all suites tinted — useful as a context plan but not as a per-suite plan. Per-suite plans usually only appear in the brochure.

## Lease tab — per-suite detail

`/detail/lookup/{id}/lease` lists every available suite with a clickable row. Each row links to a per-suite detail page that has:

- Suite-specific photo gallery (sometimes; depends on whether the listing broker uploaded photos)
- A marketing description block with prose like "Fully furnished plug-and-play creative space..." — this is gold for the description blurb
- Listed rent, term, services
- Listing broker contact

Always visit the per-suite pages for the floors in scope. The marketing description is usually a much better source than the building-level CoStar copy.

## Quick extraction sketch

For each property URL the user provides:

1. Navigate to `/summary` — extract building fields and Space table; record Documents PDF URLs.
2. For each requested floor, navigate to that suite's lease detail page — extract description prose and any per-suite photos.
3. Navigate to `/images` — pull every `<img alt>` and its `src`.
4. Download every Documents PDF to `brochures/`.

The whole sequence is documented end-to-end in `scripts/extract_costar_data.js`.
