Hướng dẫn tích hợp Housing Market API
Các bảng tham chiếu, mô tả endpoint, mã lỗi và ví dụ được tạo từ đặc tả API và được giữ nguyên bằng tiếng Anh ở mọi ngôn ngữ. Tên, tham số và mã đều giống nhau ở mọi nơi.
Ví dụ về yêu cầu và phản hồi
Các mẫu đọc khóa từ biến môi trường HMA_API_KEY. Các giá trị trong phản hồi chỉ mang tính minh họa.
Kiểm tra khóa và địa chỉ của bạn
GET /v1/ping
curl -H "x-api-key: $HMA_API_KEY" \
"https://api.housingmarketapi.com/v1/ping"{
"ok": true,
"revision": "3f9c2a1",
"key": "acme-live",
"address": "203.0.113.7"
}Liệt kê bất động sản
GET /v1/properties
curl -H "x-api-key: $HMA_API_KEY" \
"https://api.housingmarketapi.com/v1/properties?country=TH&listing_type=sale&property_type=condominium&limit=100"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);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"]{
"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
}Đọc một endpoint Insights
GET /v1/insights/prices
{
"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
}Một lỗi
{
"error": "upgrade_required",
"message": "Insights are included in the Advanced tier."
}