-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
192 lines (150 loc) · 5.26 KB
/
examples.py
File metadata and controls
192 lines (150 loc) · 5.26 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
188
189
190
191
192
#!/usr/bin/env python3
"""
Airbnb Scraper API - Quick Start Examples
Powered by RealtyAPI.io
Get your API key at: https://www.realtyapi.io
"""
import json
from airbnb_api import AirbnbAPI
API_KEY = "YOUR_API_KEY_HERE"
api = AirbnbAPI(API_KEY)
# ─── Search Homes ───
def example_homes_by_destination():
"""Search homes by destination."""
print("\n=== Homes by Destination ===")
data = api.search_homes_by_destination(
destination="toronto, canada",
check_in="2025-06-01",
check_out="2025-06-07",
adults=2,
bedrooms=2,
type_of_place="Entire_home",
price_max=300,
)
print(json.dumps(data, indent=2))
def example_homes_by_coordinates():
"""Search homes by bounding box."""
print("\n=== Homes by Coordinates ===")
data = api.search_homes_by_coordinates(
ne_lat="44.029433", ne_lng="-79.317392",
sw_lat="43.824096", sw_lng="-79.498301",
check_in="2025-06-01", check_out="2025-06-07",
adults=2,
)
print(json.dumps(data, indent=2))
def example_homes_by_place_id():
"""Search homes by Google Place ID."""
print("\n=== Homes by Place ID ===")
data = api.search_homes_by_place_id("ChIJpTvG15DL1IkRd8S0KlBVNTI")
print(json.dumps(data, indent=2))
def example_homes_by_category():
"""Search homes by category (Countryside, Beachfront, etc.)."""
print("\n=== Homes by Category ===")
data = api.search_homes_by_category(
category_tag="Tag:4104", # Countryside
adults=2,
price_max=200,
)
print(json.dumps(data, indent=2))
def example_autocomplete():
"""Location autocomplete."""
print("\n=== Autocomplete ===")
data = api.autocomplete("paris")
print(json.dumps(data, indent=2))
# ─── Search Experiences ───
def example_experiences_by_destination():
"""Search experiences."""
print("\n=== Experiences by Destination ===")
data = api.search_experiences_by_destination(
destination="toronto, canada",
experience_type="art, cooking",
price_max=100,
)
print(json.dumps(data, indent=2))
def example_experiences_by_place_id():
"""Search experiences by place ID."""
print("\n=== Experiences by Place ID ===")
data = api.search_experiences_by_place_id("ChIJpTvG15DL1IkRd8S0KlBVNTI")
print(json.dumps(data, indent=2))
# ─── Search Services ───
def example_services():
"""Search services (photography, catering, etc.)."""
print("\n=== Services by Destination ===")
data = api.search_services_by_destination(
destination="toronto, canada",
check_in="2025-06-01",
check_out="2025-06-07",
type_of_service="Photography",
)
print(json.dumps(data, indent=2))
# ─── Details & Reviews ───
def example_home_details():
"""Get home details."""
print("\n=== Home Details ===")
data = api.get_home_details(
stay_listing_id="RGVtYW5kU3RheUxpc3Rpbmc6MTI1NTc2NzAzNTg2MDMzMTgxOQ==",
check_in="2025-06-01",
check_out="2025-06-07",
)
print(json.dumps(data, indent=2))
def example_home_reviews():
"""Get home reviews."""
print("\n=== Home Reviews ===")
data = api.get_home_reviews(
stay_listing_id="U3RheUxpc3Rpbmc6MTExNjA4Mjc3OTc0NDI3OTM4Nw==",
review_limit="10",
sorting_preference="most_recent",
)
print(json.dumps(data, indent=2))
def example_home_availability():
"""Get home availability calendar."""
print("\n=== Home Availability ===")
data = api.get_home_availability("868126372367701281")
print(json.dumps(data, indent=2))
def example_experience_details():
"""Get experience details."""
print("\n=== Experience Details ===")
data = api.get_experience_details("QWN0aXZpdHlMaXN0aW5nOjMxMDk1ODQ=")
print(json.dumps(data, indent=2))
def example_experience_reviews():
"""Get experience reviews."""
print("\n=== Experience Reviews ===")
data = api.get_experience_reviews(
experience_listing_id="U3RheUxpc3Rpbmc6OTQxOTg1NTQyMTc4NDcxMjA0",
review_limit="10",
)
print(json.dumps(data, indent=2))
def example_service_details():
"""Get service details."""
print("\n=== Service Details ===")
data = api.get_service_details("QWN0aXZpdHlMaXN0aW5nOjYwNjcyNzE=")
print(json.dumps(data, indent=2))
# ─── Filters ───
def example_categories():
"""Get all Airbnb categories."""
print("\n=== Categories ===")
data = api.get_categories()
print(json.dumps(data, indent=2))
def example_amenities_filter():
"""Get amenity IDs for search."""
print("\n=== Amenities Filter ===")
data = api.get_amenities_filter()
print(json.dumps(data, indent=2))
# ─── Run ───
if __name__ == "__main__":
example_homes_by_destination()
# example_homes_by_coordinates()
# example_homes_by_place_id()
# example_homes_by_category()
# example_autocomplete()
# example_experiences_by_destination()
# example_experiences_by_place_id()
# example_services()
# example_home_details()
# example_home_reviews()
# example_home_availability()
# example_experience_details()
# example_experience_reviews()
# example_service_details()
# example_categories()
# example_amenities_filter()