Skip to Content
Technical GuideAPI Services

API Services

The frontend reaches data through a set of service classes under src/services/API/, each extending a shared APIBase. They call a proxy backend at NEXT_PUBLIC_API_URL (apiUrl = NEXT_PUBLIC_API_URL + /api), which forwards to the Repliers API.

The frontend never calls the Repliers API directly — always the proxy (@configs/api apiUrl). Don’t hard-code Repliers hosts.

User filters (Filters) services/Search/types.ts │ adapter / processParams (services/Search) ▼ Raw query params (ApiQueryParams) services/API/types/search.ts │ APISearch.fetch({ get, post }) ▼ Proxy backend → Repliers API → MLS ▼ ApiQueryResponse { listings: ApiListing[], count, statistics, aggregates } │ transformers (services/Search) + utils/dataMapper resolvers ▼ UI-ready listings

APIBase

src/services/API/APIBase.ts — the shared fetch layer every service extends:

MemberPurpose
getAbsoluteUrl(url)Prefixes a relative path with apiUrl (absolute URLs pass through).
getHeaders()Async — sets Content-Type, X-Forwarded-* (via getForwardedFrom), and Authorization: Bearer <token> when a non-expired token exists.
fetchRaw(request, options)fetch wrapper; on 401 clears the token, on a network failure returns a synthetic 503.
fetchJSON<T>(request, options)Adds an AbortController timeout (apiRequestTimeout), parses JSON, resolves T on ok, else rejects ApiError. Server-side calls retry transient failures first — see below.
ApiError(status, data)Thrown on non-OK responses; carries the HTTP status and parsed data.

Retries on transient failures

Server-side calls (build prerender, SSR, ISR regeneration) retry before surfacing an error: 408, 425, 429, 500, 502, 503, 504, 522, 524 — plus the synthetic 503 fetchRaw returns for aborts and network errors. Attempts are capped by apiRequestRetries (3) with a linear apiRetryBackoff (1s × attempt) between them, both from @configs/api. Browser calls never retry, so user-facing failures stay immediate.

After retries, the caller decides how to handle failure. Some page paths throw; others render a fallback or keep prior state. See the actual failure register. A caller-supplied AbortSignal also bypasses APIBase’s own timeout controller.

import { APISearch } from 'services/API' const response = await APISearch.fetch({ get: params }) // → ApiQueryResponse

Service classes

All are exported from services/API (src/services/API/index.ts) as singletons and use fetch*-style methods (not getX/postX):

ClassResponsibility
APISearchListing search — fetch() → /listings/search (GET or POST) → ApiQueryResponse.
APIListingDetailsA single listing’s details + similar listings.
APILocationsLocations / geography (/locations).
APIEstimateAVM estimate create / fetch.
APIFavorites / APIImageFavoritesSaved listings / saved photos.
APISavedSearchSaved searches (CRUD + alerts).
APIUser / APIAuthUser profile / authentication (redirect flow, OTP).
APIAgent / APIFubUserAgent portal / Follow Up Boss user.
APIBuildingsBuildings / condos data.
APIChatAI NLP — fetchReply() turns a query into filters.
APIContactContact-form submissions.
APIWidgetsEmbeddable widget content.
APIPropertyGeometryProperty geometry / boundaries.
APIBase / ApiErrorBase fetch layer + typed error.

locationsToGeoJson (same folder) converts location records to GeoJSON for the map.

Caller and contract register

Source review: e30dd9b47, 2026-11-02. This table identifies entry owners; it is not a promise that every exported service has a live caller.

ServicePrincipal caller / boundaryContract details
APISearchSearchService and filter/statistics consumers/listings/search; nonempty body selects POST; fetchGraph uses /stats/graph; featured collections accept only sort/pagination
APIListingDetailsListing route and detail UIBoard-aware detail; optional property history fallback; similar listings and last-update metadata
APILocationsMap, resolver, generated treeLocation lookup/boundaries, autosuggest, demographics; source/ID handling is operation-specific
APIAuth / APIUserUserProvider and auth UIOAuth/OTP/token exchange and profile fetch/update; update uses PATCH /user
APIFavoritesFavoritesProviderCollection GET, POST MLS+board, raw DELETE by favorite id
APIImageFavoritesImageFavoritesProvider/user/assets/image-favorites; JSON add/remove responses and image id
APISavedSearchSaveSearchProvider and search route/searches/ CRUD, decoded names; raw DELETE differs from JSON create/update
APIEstimateEstimate data/provider hooksSuggestions, property details, create/update/fetch, comparables, agent branch
APIAgentAgentClients/AgentEstimates/Agents providersAgent/client/estimate management and send-estimate action
APIFubUserEstimate SpecialOfferBanneraddTags posts to /user/boss/tag
APIBuildingsBuilding/catalog consumersBuilding retrieval/search; CMS editorial assembly is a separate boundary
APIChatBuilt-in chat and SupportAgentPOST /listings/nlp; prompt and NLP token
APIContactContact/scheduling/subscription formsMixed raw/JSON methods; see Forms
APIWidgetsStats, dashboard, estimate statistics/stats/widgets; propertyClass becomes query class
APIPropertyGeometryExported, no runtime caller found in the scanBuilds same-origin /api/geometry; no matching handler exists in the current inventory. An export does not establish endpoint availability

CMS and integration services also call local Frontend Route Handlers. These frontend inventories do not replace the backend’s complete API reference.

Transformers (where they really live)

There is no services/API/transformers/ directory. Filter/response transformation lives in:

  • services/Search/ — adapter.ts / transformers.ts map Filters ↔ ApiQueryParams (the processParams pipeline).
  • src/utils/dataMapper/ — resolvers (condo / residential) normalize a raw ApiListing into the detail sections the PDP renders.

Caching

Data fetching is native fetch + Next.js caching, with a custom production cache handler (cache-handler.js, wired in production outside Vercel) backed by Redis (redis) with ISR (revalidate) on server routes — not React Query or SWR (neither is a dependency).

Last updated on