Client examples

Client examples

Copy-pasteable snippets for the patterns you’ll actually run in production.

TypeScript / fetch (Next.js server action, Remix loader)

const BASE = 'https://api.zynplex.ca';
const KEY = process.env.ZYNPLEX_API_KEY!;
 
interface Listing {
  listingKey: string;
  mlsNumber: string | null;
  listPrice: number | null;
  bedrooms: number | null;
  bathrooms: number | null;
  addressLine: string | null;
  city: string | null;
  primaryImageUrl: string | null;
  listOfficeName: string | null;
}
 
interface SearchResponse {
  totalCount: number;
  totalPages: number;
  listings: Listing[];
}
 
export async function searchListings(params: Record<string, string | number>) {
  const qs = new URLSearchParams(
    Object.entries(params).map(([k, v]) => [k, String(v)])
  );
  const res = await fetch(`${BASE}/listings?${qs}`, {
    headers: { 'X-API-KEY': KEY },
    // Cache for 5 minutes — CREA data is at most 10 minutes stale anyway.
    next: { revalidate: 300 },
  });
  if (!res.ok) throw new Error(`Listings search failed: ${res.status}`);
  return (await res.json()) as SearchResponse;
}
 
// Usage in a server component:
const results = await searchListings({
  city: 'Windsor',
  minPrice: 300_000,
  status: 'Active',
  resultsPerPage: 24,
});

React listing card

import Image from 'next/image';
 
export function ListingCard({ listing }: { listing: Listing }) {
  return (
    <article className="rounded-xl overflow-hidden bg-white shadow-sm">
      {listing.primaryImageUrl && (
        <div className="relative aspect-[4/3]">
          <Image
            src={listing.primaryImageUrl}
            alt={listing.addressLine ?? 'Listing'}
            fill
            className="object-cover"
          />
        </div>
      )}
      <div className="p-4">
        <div className="text-xl font-semibold">
          ${listing.listPrice?.toLocaleString('en-CA')}
        </div>
        <div className="mt-1 text-sm text-gray-600">
          {listing.bedrooms} bd · {listing.bathrooms} ba
        </div>
        <div className="mt-2 text-sm">{listing.addressLine}, {listing.city}</div>
        {listing.listOfficeName && (
          <div className="mt-3 text-xs text-gray-500">
            {listing.listOfficeName}
          </div>
        )}
      </div>
    </article>
  );
}

curl one-liners

# Search
curl -H "X-API-KEY: $KEY" \
     "https://api.zynplex.ca/listings?city=Windsor&minPrice=400000&maxPrice=700000"
 
# Single listing
curl -H "X-API-KEY: $KEY" \
     "https://api.zynplex.ca/listings/26010382" | jq
 
# This weekend's open houses
curl -H "X-API-KEY: $KEY" \
     "https://api.zynplex.ca/open-houses?city=Windsor&from=2026-05-16T00:00:00Z&to=2026-05-18T23:59:59Z" | jq
 
# City autocomplete
curl -H "X-API-KEY: $KEY" \
     "https://api.zynplex.ca/locations/autocomplete?q=wind"
 
# Get aggregates for the current search
curl -H "X-API-KEY: $KEY" \
     "https://api.zynplex.ca/listings/aggregates?city=Windsor&status=Active" | jq

Python (requests)

import os
import requests
 
BASE = "https://api.zynplex.ca"
KEY = os.environ["ZYNPLEX_API_KEY"]
 
session = requests.Session()
session.headers.update({"X-API-KEY": KEY})
 
# Search
resp = session.get(
    f"{BASE}/listings",
    params={"city": "Windsor", "minPrice": 400_000, "status": "Active"},
    timeout=10,
)
resp.raise_for_status()
listings = resp.json()["listings"]
 
for l in listings[:5]:
    print(f'{l["listPrice"]:>8} · {l["bedrooms"]}bd · {l["addressLine"]}')

Drop this somewhere on every page that displays listing data:

export function Attribution({ a }: { a: { provider: string; statement: string; logoUrl: string } }) {
  return (
    <footer className="border-t border-gray-200 py-6 text-xs text-gray-500">
      <div className="container mx-auto px-4 flex items-center gap-4">
        <img src={a.logoUrl} alt={a.provider} width={120} height={32} />
        <p>{a.statement}</p>
      </div>
    </footer>
  );
}

/listings responses include this as attribution; render once per page.