دليل التكامل مع Housing Market API

تُولَّد الجداول المرجعية وأوصاف نقاط النهاية ورموز الأخطاء والأمثلة من مواصفات API، وتبقى باللغة الإنجليزية في كل اللغات. الأسماء والمعاملات والرموز متطابقة في كل مكان.

أمثلة على الطلبات والاستجابات

تقرأ الأمثلة المفتاح من متغير البيئة HMA_API_KEY. القيم الواردة في الاستجابات توضيحية.

التحقق من مفتاحكم وعنوانكم

GET /v1/ping

curl
curl -H "x-api-key: $HMA_API_KEY" \
  "https://api.housingmarketapi.com/v1/ping"
Response ok
{
  "ok": true,
  "revision": "3f9c2a1",
  "key": "acme-live",
  "address": "203.0.113.7"
}

عرض قائمة العقارات

GET /v1/properties

curl
curl -H "x-api-key: $HMA_API_KEY" \
  "https://api.housingmarketapi.com/v1/properties?country=TH&listing_type=sale&property_type=condominium&limit=100"
Node.js
const base = 'https://api.housingmarketapi.com';
const headers = { 'x-api-key': process.env.HMA_API_KEY };

let cursor;
do {
  const url = new URL('/v1/properties', base);
  url.searchParams.set('country', 'TH');
  url.searchParams.set('listing_type', 'sale');
  if (cursor) url.searchParams.set('cursor', cursor);

  const res = await fetch(url, { headers });
  if (!res.ok) throw new Error(`${res.status} ${(await res.json()).error}`);
  const page = await res.json();

  for (const property of page.data) console.log(property.id, property.price);
  cursor = page.next_cursor ?? undefined;
} while (cursor);
Python
import os
import requests

base = "https://api.housingmarketapi.com"
headers = {"x-api-key": os.environ["HMA_API_KEY"]}
params = {"country": "TH", "listing_type": "sale"}

while True:
    res = requests.get(f"{base}/v1/properties", headers=headers, params=params)
    res.raise_for_status()
    page = res.json()
    for prop in page["data"]:
        print(prop["id"], prop["price"])
    if not page["next_cursor"]:
        break
    params["cursor"] = page["next_cursor"]
Response firstPage
{
  "data": [
    {
      "id": "kQ3vXr0bT1uYvW2aP8sLgA",
      "country": "TH",
      "listing_type": "sale",
      "property_type": "condominium",
      "province": "Example Province",
      "province_id": 1,
      "city": "Example City",
      "city_id": 11,
      "area": "Example District",
      "area_id": 111,
      "address": "Example Road",
      "post_code": null,
      "latitude": 13.75,
      "longitude": 100.5,
      "location_precision": "approximate",
      "price": 4500000,
      "price_max": null,
      "currency": "THB",
      "bedrooms": 2,
      "bathrooms": 2,
      "rooms": null,
      "living_area": 65,
      "living_area_sqm": 65,
      "lot_area": null,
      "lot_area_sqm": null,
      "build_year": 2019,
      "published_date": "2026-09-01T00:00:00Z",
      "last_updated": "2026-10-02T08:30:00Z",
      "features": [],
      "appliances": [],
      "neighbourhood": [],
      "tags": [],
      "developer": "Example Developer Co., Ltd.",
      "summary": "Bright two-bedroom condominium close to the station.",
      "description": "Bright two-bedroom condominium close to the station. Quiet building with a pool and gym.",
      "location_text": null,
      "images": []
    }
  ],
  "next_cursor": "EXAMPLE-OPAQUE-CURSOR",
  "has_more": true
}

قراءة نقطة نهاية Insights

GET /v1/insights/prices

Response monthly
{
  "data": [
    {
      "period_start": "2026-09-01",
      "period_end": "2026-09-30",
      "geography": {
        "level": "city",
        "id": 11,
        "name": "Example City"
      },
      "suppressed": false,
      "currency": "THB",
      "median_price": 4200000,
      "median_price_per_sqm": 68000,
      "listing_count": 310
    }
  ],
  "meta": {
    "country": "TH",
    "level": "city",
    "granularity": "month",
    "suppression_min_cell": 10
  },
  "next_cursor": null,
  "has_more": false
}

خطأ

HTTP 403
{
  "error": "upgrade_required",
  "message": "Insights are included in the Advanced tier."
}