EstateHub

Customer AI Search API

Base URL: http://localhost:8000/api/v1
Prefix: /customers/properties
Auth: Public; JWT optional
Headers: Content-Type: application/json


1. Search Properties Using Natural Language

Interpret a natural-language query and retrieve matching available listings.

POST/customers/properties/ai-search/

Auth: Not required

Request Body

JSON
{
  "query": "Apartments for rent in Austin with at least 3 bedrooms under USD 2,500"
}

Success Example

JSON
{
  "success": true,
  "message": "AI property search completed successfully.",
  "data": {
    "filters": {
      "property_type": "apartment",
      "purpose": "rent",
      "city": "Austin",
      "currency": "USD",
      "max_price": "2500.00",
      "bedrooms": 3
    },
    "assumptions": [
      "Bedrooms is a minimum count."
    ],
    "unsupported_requirements": [],
    "properties": {
      "count": 0,
      "next": null,
      "previous": null,
      "results": []
    }
  }
}

Notes

  • Public access is allowed without a JWT or customer role. Authenticated users may supply a valid JWT; invalid or expired tokens still return 401. Ordinary GET discovery retains its existing public access.
  • query is required, trimmed, nonblank, and at most 1000 characters. The request body accepts only query; callers cannot choose providers, models, credentials, or arbitrary filters.
  • Optional URL parameters are page and page_size. Defaults are page 1 and 12 results, with at most 50 results per page. page=last follows existing pagination behavior. An invalid/out-of-range page returns 404 after interpretation.
  • The result example shows no matching inventory. Matching listings use the same response fields as Property Discovery; the provider never creates listings or directly queries the database.
  • Supported filters are q, property_type, purpose, city, area_name, currency, min_price, max_price, bedrooms, bathrooms, amenities, and ordering. Null/unspecified fields are omitted. Prices are decimal strings with up to 14 digits and 2 decimal places. Prices and bedroom/bathroom minimums must be nonnegative; counts are at most 100. Minimum price cannot exceed maximum price.
  • Only available buy/rent listings are eligible. Draft, pending, reserved, hidden, sold, and rented listings are excluded. Existing property types and supported platform currencies (USD, BDT, EUR, GBP) are validated.
  • Prices are compared only within the returned currency. When omitted, currency defaults to the platform setting and is disclosed in assumptions. There is no currency conversion or rental price-period conversion.
  • Locations are resolved case-insensitively to a unique stored name when possible, then applied using existing exact-match filters. Unrecognized locations remain exact filters and may return zero results. Ambiguous stored names return 400; locations are not silently removed.
  • Bedrooms and bathrooms are minimum counts. Amenities match any requested active slug, preserving existing search behavior; there may be up to 20 requested slugs. The prompt includes at most 200 active amenity names/slugs. Unsupported requirements are reported separately and are not guaranteed by the results; callers should display them alongside assumptions.
  • School proximity, commute times, exact bedroom counts, all-amenity matching, area-size requirements, auction/invest purposes, and price-period conversion are not enforced by this version. A query with no usable criteria returns 400 instead of searching the entire inventory.
  • Ordering accepts price, -price, newest, -created_at, featured, and trending. The returned filters are reusable with GET /customers/properties/; that endpoint now supports optional case-insensitive currency filtering.
  • Pagination next and previous links point to ordinary GET discovery with the interpreted filters. Follow these links without resubmitting the AI query. Amenity parameters use repeated query keys. Posting the query again invokes the provider again.
  • The selected provider receives the user's query, interpretation instructions, and up to 200 active amenity names/slugs. It does not receive listing inventory, account details, or private documents. Avoid sensitive personal information in queries.
  • Defaults: 10 requests/minute per authenticated user, or per IP address for anonymous visitors; 20-second network inactivity timeout; 2048 output tokens; 64 KiB provider response limit. Runtime timeout and token settings are clamped to 1–60 seconds and 256–4096 tokens. Configure a shared Django cache for throttling across processes and provider-side spending limits; throttling is approximate and is not a hard billing cap.
  • Provider interpretation may still misunderstand natural language. Review returned filters and notes. No automatic retries, failover, or silent fallback broadens the search. Existing ordinary property search is available separately.
  • Configure the feature through the Administrator AI Search Integration API.
  • Applicable errors are listed below. Error responses use the shared envelope; provider bodies and credentials are not exposed.
HTTP statusCondition
400Invalid/missing/oversized query, unknown body field, malformed JSON, no usable criteria, ambiguous location, or provider refusal
401Invalid or expired JWT, if supplied
404Invalid or out-of-range page
405HTTP method is not supported
406Requested response format is not supported
415Request content type is not supported
429Per-user or anonymous IP request limit exceeded; response includes Retry-After
502Provider HTTP/network failure, truncated/malformed/oversized output, invalid schema/filter values, or inactive/unknown amenity
503AI search is disabled or selected provider configuration cannot be loaded
504Provider network timeout

Common Success Format

JSON
{
  "success": true,
  "message": "AI property search completed successfully.",
  "data": {
    "filters": {},
    "assumptions": [],
    "unsupported_requirements": [],
    "properties": {
      "count": 0,
      "next": null,
      "previous": null,
      "results": []
    }
  }
}

Common Error Format

JSON
{
  "success": false,
  "message": "Validation failed.",
  "errors": {
    "query": [
      "This field is required."
    ]
  }
}

Errors with a single detail message return an empty errors object. For example, HTTP 503:

JSON
{
  "success": false,
  "message": "AI search is disabled or not configured.",
  "errors": {}
}