# Types

Every type the package exports, with its fields. Data types come from the package root; each component's props type is exported next to the component.

```ts
import type {
  RealEstateListing,
  SearchListingsOptions,
  ListingSearchResult,
  ListingPaginationInfo,
} from '@sonordev/re-site-kit'
import type { ListingGalleryProps } from '@sonordev/re-site-kit/client'
import type { RealEstateMcpOptions } from '@sonordev/re-site-kit/mcp'
```

## RealEstateListing

One listing, in the same shape whichever serve mode your project uses. Most fields are nullable: feeds don't fill everything, and listings entered by hand fill only some of it.

### Identity

| Field               | Type             | What it is                                                      |
| ------------------- | ---------------- | --------------------------------------------------------------- |
| `id`                | `string`         | Sonor's id for the listing. Stable, so use it as a React `key`. |
| `site`              | `string`         | The sub-site host on a multi-site project.                      |
| `source`            | `string`         | Where the listing came from: the MLS feed, or entered by hand.  |
| `source_listing_id` | `string \| null` | The MLS number.                                                 |
| `source_url`        | `string \| null` | The listing's page at its source.                               |
| `slug`              | `string \| null` | The listing's URL slug on your site.                            |

### Status

| Field            | Type               | What it is                                             |
| ---------------- | ------------------ | ------------------------------------------------------ |
| `status`         | `ListingStatus`    | `active`, `pending`, `sold`, `expired` or `withdrawn`. |
| `type`           | `ListingType`      | `sale`, `rent` or `lease`.                             |
| `listing_date`   | `string \| null`   | When it was listed.                                    |
| `days_on_market` | `number \| null`   | Days on market.                                        |
| `featured`       | `boolean`          | Marked as featured.                                    |
| `tags`           | `string[] \| null` | Tags.                                                  |

### Location

| Field                                       | Type                                                                                                                                                                   |
| ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `address`                                   | `string`                                                                                                                                                               |
| `unit_number`                               | `string \| null`                                                                                                                                                       |
| `city`, `state`, `zip`, `county`, `country` | `string \| null`                                                                                                                                                       |
| `neighborhood`                              | `string \| null`                                                                                                                                                       |
| `building_name`                             | `string \| null`                                                                                                                                                       |
| `latitude`, `longitude`                     | `number \| null`                                                                                                                                                       |
| `building`                                  | `ListingBuildingRef \| null` (optional): the building Sonor matched it to. See [Buildings](https://sonor.dev/re-site-kit/buildings#linking-a-listing-to-its-building). |

### The property

| Field                                                       | Type                   |
| ----------------------------------------------------------- | ---------------------- |
| `property_type`                                             | `PropertyType \| null` |
| `year_built`                                                | `number \| null`       |
| `square_feet`, `lot_size_sqft`                              | `number \| null`       |
| `bedrooms`, `bathrooms`, `full_bathrooms`, `half_bathrooms` | `number \| null`       |
| `garage_spaces`, `stories`, `floor_level`                   | `number \| null`       |
| `features`                                                  | `string[] \| null`     |

### Price and fees

| Field                | Type               | What it is                                                                                                                           |
| -------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `price`              | `number \| null`   | List price.                                                                                                                          |
| `price_display`      | `string \| null`   | The feed's own formatted price, when it has one. `formatPrice` prefers it.                                                           |
| `price_per_sqft`     | `number \| null`   | Price per square foot.                                                                                                               |
| `currency`           | `string \| null`   | Currency code. Treated as `USD` when missing.                                                                                        |
| `hoa_fee`            | `number \| null`   | HOA fee, per `hoa_frequency`.                                                                                                        |
| `hoa_frequency`      | `string \| null`   | How often the fee is due, e.g. "Monthly" or "Quarterly". See [monthlyHoa](https://sonor.dev/re-site-kit/market-snapshot#monthlyhoa). |
| `hoa_includes`       | `string[] \| null` | What the HOA fee covers.                                                                                                             |
| `building_amenities` | `string[] \| null` | Shared amenities.                                                                                                                    |
| `pets_allowed`       | `boolean \| null`  | Whether pets are allowed, when the listing says.                                                                                     |
| `pet_restrictions`   | `string \| null`   | Pet rules.                                                                                                                           |

### Media and copy

| Field                                             | Type                                                  |
| ------------------------------------------------- | ----------------------------------------------------- |
| `images`                                          | `string[] \| null`                                    |
| `virtual_tour_url`, `video_url`, `floor_plan_url` | `string \| null`                                      |
| `description`, `remarks_public`                   | `string \| null`                                      |
| `seo_title`, `seo_description`                    | `string \| null` (used by `listingMetadata` when set) |

### Listing agent and brokerage

| Field                                                              | Type                                                     |
| ------------------------------------------------------------------ | -------------------------------------------------------- |
| `listing_agent_name`, `listing_agent_email`, `listing_agent_phone` | `string \| null`                                         |
| `listing_office_name`                                              | `string \| null` (the listing brokerage, for IDX credit) |

### Other

| Field                      | Type                                    | What it is                                                                           |
| -------------------------- | --------------------------------------- | ------------------------------------------------------------------------------------ |
| `open_houses`              | `ListingOpenHouse[] \| null` (optional) | Upcoming open houses. Present on a single listing from a project in live serve mode. |
| `created_at`, `updated_at` | `string`                                | ISO 8601 timestamps. `IdxAttribution` shows `updated_at`.                            |

## Small types

```ts
type ListingStatus = 'active' | 'pending' | 'sold' | 'expired' | 'withdrawn'
type ListingType = 'sale' | 'rent' | 'lease'
type PropertyType =
  | 'single_family'
  | 'condo'
  | 'townhouse'
  | 'multi_family'
  | 'land'
  | 'commercial'
  | 'other'

interface ListingOpenHouse {
  date: string | null
  start_time: string | null
  end_time: string | null
  comments: string | null
}

interface ListingBuildingRef {
  slug: string
  name: string
  url: string | null
}
```

## Search

| Type                    | What it is                                                                                                                                                                                                                                                                                                                                  |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SearchListingsOptions` | `searchListings`' options: `site`, `status`, `type`, `city`, `zip`, `neighborhood`, `minPrice`, `maxPrice`, `bedsMin`, `bathsMin`, `propertyType`, `building`, `q`, `sort` (`'price_asc' \| 'price_desc' \| 'newest' \| 'updated'`), `page`, `limit`. All optional. See [Search and filters](https://sonor.dev/re-site-kit/search#options). |
| `ListingSearchResult`   | `{ listings: RealEstateListing[]; pagination: ListingPaginationInfo }`                                                                                                                                                                                                                                                                      |
| `ListingPaginationInfo` | `{ page: number; page_size: number; total: number \| null; total_pages: number \| null }`. It's named `ListingPagination` in the source; the root export renames it so it doesn't clash with the `ListingPagination` component.                                                                                                             |
| `GetListingsOptions`    | `getListings`' options: `site`, `status`, `type`, `limit`, `offset`. All optional.                                                                                                                                                                                                                                                          |

## Hot properties

| Type                    | What it is                                                                                                                                              |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GetHotListingsOptions` | `{ site?: string; window?: string; limit?: number }`                                                                                                    |
| `HotListingEntry`       | `{ listing: RealEstateListing; views: number; unique_viewers: number; prior_views: number; trend_pct: number \| null; last_viewed_at: string \| null }` |
| `HotListingsResult`     | `{ window_hours: number; listings: HotListingEntry[] }`, the API's raw response. `getHotListings` returns just the `listings` array.                    |

See [Hot properties](https://sonor.dev/re-site-kit/hot-listings).

## Buildings and stats

| Type                    | What it is                                                                                                                                                                                                                                                                      |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `BuildingRegistryEntry` | One building in your registry: `slug` and `name` required; `id`, `aliases`, `addresses`, `city`, `state`, `zip`, `latitude`, `longitude`, `radius_m`, `url` optional. See [the registry](https://sonor.dev/re-site-kit/buildings#registry-entries).                             |
| `BuildingSummary`       | `{ slug: string; name: string; url: string \| null; external_id: string \| null; active_count: number; price_min: number \| null; price_max: number \| null }`                                                                                                                  |
| `ListingStats`          | What `summarizeListings` returns: `count`, `priceMin`, `priceMax`, `medianPrice`, `medianPricePerSqft`, `medianSqft`, `medianMonthlyHoa`, `medianDaysOnMarket`, `bedsMin`, `bedsMax`, `petFriendlyShare`. See [Market snapshot](https://sonor.dev/re-site-kit/market-snapshot). |

## JSON-LD

| Type                   | What it is                                                                           |
| ---------------------- | ------------------------------------------------------------------------------------ |
| `ListingJsonLdOptions` | `{ url?: string; siteName?: string }`, for `buildListingJsonLd` and `ListingSchema`. |

## Component props

| Type                      | Import from                    | Component                                                                                       |
| ------------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------- |
| `ListingCardProps`        | `@sonordev/re-site-kit`        | [ListingCard](https://sonor.dev/re-site-kit/cards#listingcard)                                  |
| `ListingGridProps`        | `@sonordev/re-site-kit`        | [ListingGrid](https://sonor.dev/re-site-kit/cards#listinggrid)                                  |
| `ListingDetailProps`      | `@sonordev/re-site-kit`        | [ListingDetail](https://sonor.dev/re-site-kit/listing-pages#listingdetail)                      |
| `ListingSchemaProps`      | `@sonordev/re-site-kit`        | [ListingSchema](https://sonor.dev/re-site-kit/listing-pages#listingschema)                      |
| `IdxAttributionProps`     | `@sonordev/re-site-kit`        | [IdxAttribution](https://sonor.dev/re-site-kit/idx#idxattribution)                              |
| `ListingFiltersProps`     | `@sonordev/re-site-kit`        | [ListingFilters](https://sonor.dev/re-site-kit/search#listingfilters)                           |
| `ListingPaginationProps`  | `@sonordev/re-site-kit`        | [ListingPagination](https://sonor.dev/re-site-kit/search#listingpagination)                     |
| `ListingGalleryProps`     | `@sonordev/re-site-kit/client` | [ListingGallery](https://sonor.dev/re-site-kit/listing-pages#listinggallery)                    |
| `ListingInquiryFormProps` | `@sonordev/re-site-kit/client` | [ListingInquiryForm](https://sonor.dev/re-site-kit/inquiry-forms)                               |
| `ListingViewTrackerProps` | `@sonordev/re-site-kit/client` | [ListingViewTracker](https://sonor.dev/re-site-kit/hot-listings#count-views-listingviewtracker) |

## MCP

| Type                   | Import from                 | What it is                                                                                                                      |
| ---------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `RealEstateMcpOptions` | `@sonordev/re-site-kit/mcp` | The options for `realEstateMcpTools` and `realEstateMcpServerInfo`. See [MCP tools](https://sonor.dev/re-site-kit/mcp#options). |
