JavaScript & Node.js Implementation Guide
Master the Property Finder APIs and Datasets with JavaScript. Learn how to fetch UAE property listings, handle pagination, and manage asynchronous data in Node.js or the browser.
Introduction
JavaScript is the engine behind modern real estate portals. Whether you are building a server-side analytics tool with Node.js or a dynamic listing feed with React, Property Finder APIs and Datasets provides the high-fidelity data you need through a standardized REST interface.
This guide covers the essentials of authenticating and consuming UAE real estate data (via Property Finder) using modern JavaScript (ES6+) and the native fetch API.
Prerequisites
- Node.js 18+ (for native
fetchsupport) or a modern evergreen browser. - RapidAPI Credentials: You’ll need an active subscription to the Propertyfinder-UAE-Data API.
- Environment: A basic text editor and terminal.
Core Authentication
Property Finder APIs and Datasets uses the RapidAPI gateway for secure authentication. Every request must include your unique x-rapidapi-key.
/* Configuration */
const CONFIG = {
KEY: "YOUR_RAPIDAPI_KEY",
HOST: "uae-real-estate-property.p.rapidapi.com",
BASE_URL: "https://uae-real-estate-property.p.rapidapi.com"
};
const REQUEST_HEADERS = {
"x-rapidapi-key": CONFIG.KEY,
"x-rapidapi-host": CONFIG.HOST,
};
Basic Implementation: Searching the Market
The /search-buy (sale) and /search-rent (rental) endpoints are your primary tools for retrieving listings. Here is how to implement a clean, async/await function to fetch data for a specific community.
async function getUAEProperties(listing, locationId, propertyType) {
const query = new URLSearchParams({
location_id: locationId, // e.g., 50 for Dubai Marina
property_type: propertyType, // e.g., 'villa' or 'apartment'
page: "1"
});
try {
// listing: 'buy' -> /search-buy, 'rent' -> /search-rent
const response = await fetch(`${CONFIG.BASE_URL}/search-${listing}?${query}`, {
method: "GET",
headers: REQUEST_HEADERS
});
if (!response.ok) {
throw new Error(`Market Query Failed: ${response.status}`);
}
const { data, total_count } = await response.json();
console.log(`Successfully retrieved ${data.length} of ${total_count} listings.`);
return data;
} catch (err) {
console.error("API Integration Error:", err.message);
}
}
// Usage: Fetch villas for sale in Dubai
// const listings = await getUAEProperties("buy", 1, "villa");
Advanced: Aggregating Multi-Page Data
For research and bulk ingestion, you’ll need to handle pagination. Listing searches return a total_count and about 38 listings per page, with page starting at 1.
async function bulkIngestListings(locationId, maxPages = 3) {
let entries = [];
for (let p = 1; p <= maxPages; p++) {
const response = await fetch(`${CONFIG.BASE_URL}/search-buy?location_id=${locationId}&page=${p}`, {
headers: REQUEST_HEADERS
});
const result = await response.json();
const hits = result.data;
if (!hits || hits.length === 0) break;
entries = [...entries, ...hits];
console.log(`Page ${p} synced. Total so far: ${entries.length}`);
if (entries.length >= result.total_count) break;
}
return entries;
}
Production-Grade Error Handling
When building for production, always account for rate limits (HTTP 429) and malformed queries.
async function resilientFetch(endpoint, params = {}) {
const url = `${CONFIG.BASE_URL}${endpoint}?${new URLSearchParams(params)}`;
const res = await fetch(url, { headers: REQUEST_HEADERS });
switch (res.status) {
case 200:
return res.json();
case 429:
console.warn("Operational Warning: Rate limit reached. Scaling back requests.");
return null;
case 403:
console.error("Authentication Failure: Check your RapidAPI Key.");
return null;
default:
console.error(`Unexpected Market API Error: ${res.status}`);
return null;
}
}
Handling Display Text
Our API returns listing titles and full location names as plain strings, ready to display.
// Accessing display-ready text from a search result
const property = results[0];
const title = property.title; // e.g. "Vacant | Move in Now | Spacious Layout"
const address = property.address.full_name; // e.g. "Botanica Tower, Dubai Marina, Dubai"
Next Implementation Steps
- Frontend: View the React Integration Guide to build listing carousels.
- Server-Side: Explore the Next.js Guide for SEO-optimized property pages.
- Visualization: Use the Python Guide for deep data science and pricing analytics.