-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
187 lines (147 loc) · 5.93 KB
/
examples.py
File metadata and controls
187 lines (147 loc) · 5.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/env python3
"""
Bayut Scraper API - Quick Start Examples
Powered by RealtyAPI.io
These examples demonstrate how to use the Bayut Scraper API
to extract UAE real estate data from Bayut programmatically.
Get your API key at: https://www.realtyapi.io
"""
import json
from bayut_api import BayutAPI
# ─────────────────────────────────────────────
# Replace with your API key from https://www.realtyapi.io
# ─────────────────────────────────────────────
API_KEY = "YOUR_API_KEY_HERE"
api = BayutAPI(API_KEY)
# ─────────────────────────────────────────────
# Search & Autocomplete
# ─────────────────────────────────────────────
def example_autocomplete():
"""Get location IDs for property search."""
print("\n=== Autocomplete ===")
data = api.autocomplete("dubai marina")
print(json.dumps(data, indent=2))
def example_search_for_sale():
"""Search properties for sale in Dubai."""
print("\n=== Search For Sale ===")
data = api.search_property(
location_external_id="6901", # Dubai Marina
purpose="for-sale",
category="residential",
rooms="2",
min_price="500000",
max_price="3000000",
)
print(json.dumps(data, indent=2))
def example_search_for_rent():
"""Search properties for rent in Dubai."""
print("\n=== Search For Rent ===")
data = api.search_property(
location_external_id="6901",
purpose="for-rent",
rent_frequency="yearly",
rooms="1",
furnishing_status="furnished",
max_price="100000",
)
print(json.dumps(data, indent=2))
def example_search_villas():
"""Search villas for sale."""
print("\n=== Search Villas ===")
data = api.search_property(
location_external_id="6901",
purpose="for-sale",
category_external_id="3", # Villas
min_price="1000000",
)
print(json.dumps(data, indent=2))
def example_search_commercial():
"""Search commercial properties."""
print("\n=== Search Commercial ===")
data = api.search_property(
location_external_id="6901",
purpose="for-rent",
category="commercial",
category_external_id="5", # Office
)
print(json.dumps(data, indent=2))
def example_search_under_construction():
"""Search off-plan / under-construction properties."""
print("\n=== Under Construction ===")
data = api.search_property(
location_external_id="6901",
purpose="for-sale",
completion_status="under-construction",
)
print(json.dumps(data, indent=2))
# ─────────────────────────────────────────────
# Property Details
# ─────────────────────────────────────────────
def example_property_details():
"""Get full property details."""
print("\n=== Property Details ===")
data = api.get_property_details("12372178")
print(json.dumps(data, indent=2))
# ─────────────────────────────────────────────
# Agency & Agent
# ─────────────────────────────────────────────
def example_agency_details():
"""Get agency details."""
print("\n=== Agency Details ===")
data = api.get_agency_details("10499")
print(json.dumps(data, indent=2))
def example_agent_details():
"""Get agent profile."""
print("\n=== Agent Details ===")
data = api.get_agent_details("salma-mohamed-mahmoud-hashem-2521536")
print(json.dumps(data, indent=2))
def example_agents_by_agency():
"""Get all agents in an agency."""
print("\n=== Agents by Agency ===")
data = api.get_agents_by_agency("10499")
print(json.dumps(data, indent=2))
def example_agent_deals_count():
"""Get agent claimed deals count."""
print("\n=== Agent Deals Count ===")
data = api.get_agent_claimed_deals_count("1919589")
print(json.dumps(data, indent=2))
def example_agent_deals_total():
"""Get agent claimed deals total price."""
print("\n=== Agent Deals Total Price ===")
data = api.get_agent_claimed_deals_total_price("1919589")
print(json.dumps(data, indent=2))
def example_agent_stories():
"""Get agent stories."""
print("\n=== Agent Stories ===")
data = api.get_agent_stories("1919589")
print(json.dumps(data, indent=2))
def example_trubroker_search():
"""Search TruBroker verified agents."""
print("\n=== TruBroker Agents ===")
data = api.search_trubroker_agents(
location_external_id="5152",
category="residential",
purpose="for-sale",
)
print(json.dumps(data, indent=2))
# ─────────────────────────────────────────────
# Run examples (uncomment the ones you want)
# ─────────────────────────────────────────────
if __name__ == "__main__":
# Search
example_autocomplete()
# example_search_for_sale()
# example_search_for_rent()
# example_search_villas()
# example_search_commercial()
# example_search_under_construction()
# Details
# example_property_details()
# Agent
# example_agency_details()
# example_agent_details()
# example_agents_by_agency()
# example_agent_deals_count()
# example_agent_deals_total()
# example_agent_stories()
# example_trubroker_search()