airbnb-search 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ """Airbnb Search Tool - Search Airbnb listings without broken PDP calls."""
2
+
3
+ from .search import search_airbnb, parse_listings
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["search_airbnb", "parse_listings"]
airbnb_search/cli.py ADDED
@@ -0,0 +1,76 @@
1
+ """Command-line interface for Airbnb Search."""
2
+
3
+ import argparse
4
+ import json
5
+ import sys
6
+ from .search import search_airbnb, parse_listings
7
+
8
+
9
+ def print_listings(result: dict, format: str = 'table'):
10
+ """Print listings in specified format."""
11
+ listings = result['listings']
12
+
13
+ if format == 'json':
14
+ print(json.dumps(result, indent=2))
15
+ return
16
+
17
+ print(f"\nšŸ“ {result['location']}")
18
+ print(f"šŸ“Š Found {result['total_count']} total listings\n")
19
+ print("=" * 90)
20
+
21
+ sorted_listings = sorted(
22
+ [l for l in listings if l['total_price_num']],
23
+ key=lambda x: x['total_price_num']
24
+ )
25
+
26
+ for listing in sorted_listings:
27
+ name = listing['name'][:50] + '...' if len(listing['name']) > 50 else listing['name']
28
+ rating = f"⭐{listing['rating']}" if listing['rating'] else "No rating"
29
+ superhost = "šŸ†" if listing['is_superhost'] else ""
30
+
31
+ print(f"{name} {superhost}")
32
+ print(f" {listing['bedrooms']}BR/{listing['bathrooms']}BA | {rating} | {listing['reviews_count'] or 0} reviews")
33
+ print(f" šŸ’° {listing['total_price']} {listing['price_qualifier']}")
34
+ if listing['original_price']:
35
+ print(f" (was {listing['original_price']})")
36
+ print(f" šŸ”— {listing['url']}")
37
+ print()
38
+
39
+
40
+ def main():
41
+ parser = argparse.ArgumentParser(
42
+ description='Search Airbnb listings from the command line',
43
+ prog='airbnb-search'
44
+ )
45
+ parser.add_argument('query', help='Search location (e.g., "Steamboat Springs, CO")')
46
+ parser.add_argument('--checkin', '-i', help='Check-in date (YYYY-MM-DD)')
47
+ parser.add_argument('--checkout', '-o', help='Check-out date (YYYY-MM-DD)')
48
+ parser.add_argument('--min-price', type=int, help='Minimum price')
49
+ parser.add_argument('--max-price', type=int, help='Maximum price')
50
+ parser.add_argument('--min-bedrooms', type=int, help='Minimum bedrooms')
51
+ parser.add_argument('--limit', type=int, default=50, help='Max results (default: 50)')
52
+ parser.add_argument('--format', '-f', choices=['table', 'json'], default='table',
53
+ help='Output format (default: table)')
54
+
55
+ args = parser.parse_args()
56
+
57
+ try:
58
+ data = search_airbnb(
59
+ query=args.query,
60
+ checkin=args.checkin,
61
+ checkout=args.checkout,
62
+ min_price=args.min_price,
63
+ max_price=args.max_price,
64
+ min_bedrooms=args.min_bedrooms,
65
+ items_per_page=args.limit,
66
+ )
67
+ result = parse_listings(data)
68
+ print_listings(result, args.format)
69
+
70
+ except Exception as e:
71
+ print(f"Error: {e}", file=sys.stderr)
72
+ sys.exit(1)
73
+
74
+
75
+ if __name__ == '__main__':
76
+ main()
@@ -0,0 +1,148 @@
1
+ """Core search functionality for Airbnb."""
2
+
3
+ import json
4
+ import requests
5
+ from typing import Optional, Dict, List, Any
6
+
7
+ API_KEY = 'd306zoyjsyarp7ifhu67rjxn52tv0t20'
8
+ API_URL = 'https://www.airbnb.com/api/v3/ExploreSearch'
9
+
10
+
11
+ def search_airbnb(
12
+ query: str,
13
+ checkin: Optional[str] = None,
14
+ checkout: Optional[str] = None,
15
+ min_price: Optional[int] = None,
16
+ max_price: Optional[int] = None,
17
+ min_bedrooms: Optional[int] = None,
18
+ items_per_page: int = 50,
19
+ currency: str = 'USD'
20
+ ) -> Dict[str, Any]:
21
+ """
22
+ Search Airbnb and return raw API results.
23
+
24
+ Args:
25
+ query: Search location (e.g., "Steamboat Springs, CO")
26
+ checkin: Check-in date (YYYY-MM-DD)
27
+ checkout: Check-out date (YYYY-MM-DD)
28
+ min_price: Minimum price filter
29
+ max_price: Maximum price filter
30
+ min_bedrooms: Minimum bedrooms filter
31
+ items_per_page: Number of results (max 50)
32
+ currency: Currency code (default: USD)
33
+
34
+ Returns:
35
+ Raw API response as dict
36
+ """
37
+ headers = {'x-airbnb-api-key': API_KEY}
38
+
39
+ request_params = {
40
+ 'metadataOnly': False,
41
+ 'version': '1.7.9',
42
+ 'itemsPerGrid': items_per_page,
43
+ 'tabId': 'home_tab',
44
+ 'refinementPaths': ['/homes'],
45
+ 'source': 'structured_search_input_header',
46
+ 'searchType': 'filter_change',
47
+ 'query': query,
48
+ 'cdnCacheSafe': False,
49
+ 'simpleSearchTreatment': 'simple_search_only',
50
+ }
51
+
52
+ if checkin:
53
+ request_params['checkin'] = checkin
54
+ if checkout:
55
+ request_params['checkout'] = checkout
56
+ if min_price:
57
+ request_params['priceMin'] = min_price
58
+ if max_price:
59
+ request_params['priceMax'] = max_price
60
+ if min_bedrooms:
61
+ request_params['minBedrooms'] = min_bedrooms
62
+
63
+ variables = {'request': request_params}
64
+ extensions = {
65
+ 'persistedQuery': {
66
+ 'version': 1,
67
+ 'sha256Hash': '13aa9971e70fbf5ab888f2a851c765ea098d8ae68c81e1f4ce06e2046d91b6ea'
68
+ }
69
+ }
70
+
71
+ var_str = json.dumps(variables, separators=(',', ':'))
72
+ ext_str = json.dumps(extensions, separators=(',', ':'))
73
+
74
+ full_url = f'{API_URL}?operationName=ExploreSearch&locale=en&currency={currency}&variables={var_str}&extensions={ext_str}'
75
+
76
+ response = requests.get(full_url, headers=headers)
77
+ response.raise_for_status()
78
+ return response.json()
79
+
80
+
81
+ def parse_listings(data: Dict[str, Any]) -> Dict[str, Any]:
82
+ """
83
+ Parse raw API response into clean listing data.
84
+
85
+ Args:
86
+ data: Raw API response from search_airbnb()
87
+
88
+ Returns:
89
+ Dict with 'listings', 'total_count', 'has_next_page', and 'location'
90
+ """
91
+ listings = []
92
+
93
+ ev3 = data.get('data', {}).get('dora', {}).get('exploreV3', {})
94
+ metadata = ev3.get('metadata', {})
95
+ geography = metadata.get('geography', {})
96
+ pagination = metadata.get('paginationMetadata', {})
97
+
98
+ for section in ev3.get('sections', []):
99
+ if section.get('__typename') != 'DoraExploreV3ListingsSection':
100
+ continue
101
+
102
+ for item in section.get('items', []):
103
+ listing = item.get('listing', {})
104
+ pricing = item.get('pricingQuote', {})
105
+
106
+ price_struct = pricing.get('structuredStayDisplayPrice', {})
107
+ primary = price_struct.get('primaryLine', {})
108
+
109
+ total_price = primary.get('discountedPrice') or primary.get('price', '')
110
+ original_price = primary.get('originalPrice', '')
111
+ qualifier = primary.get('qualifier', '')
112
+
113
+ price_num = None
114
+ if total_price:
115
+ try:
116
+ price_num = int(''.join(c for c in total_price if c.isdigit()))
117
+ except:
118
+ pass
119
+
120
+ listings.append({
121
+ 'id': listing.get('id'),
122
+ 'name': listing.get('name'),
123
+ 'url': f"https://airbnb.com/rooms/{listing.get('id')}",
124
+ 'bedrooms': listing.get('bedrooms'),
125
+ 'bathrooms': listing.get('bathrooms'),
126
+ 'beds': listing.get('beds'),
127
+ 'rating': listing.get('avgRating'),
128
+ 'reviews_count': listing.get('reviewsCount'),
129
+ 'room_type': listing.get('roomType'),
130
+ 'property_type': listing.get('propertyType'),
131
+ 'person_capacity': listing.get('personCapacity'),
132
+ 'is_superhost': listing.get('isSuperhost'),
133
+ 'city': listing.get('city') or geography.get('city'),
134
+ 'lat': listing.get('lat'),
135
+ 'lng': listing.get('lng'),
136
+ 'total_price': total_price,
137
+ 'total_price_num': price_num,
138
+ 'original_price': original_price,
139
+ 'price_qualifier': qualifier,
140
+ 'can_instant_book': pricing.get('canInstantBook'),
141
+ })
142
+
143
+ return {
144
+ 'listings': listings,
145
+ 'total_count': pagination.get('totalCount'),
146
+ 'has_next_page': pagination.get('hasNextPage'),
147
+ 'location': geography.get('fullAddress'),
148
+ }
@@ -0,0 +1,96 @@
1
+ Metadata-Version: 2.4
2
+ Name: airbnb-search
3
+ Version: 0.1.0
4
+ Summary: Search Airbnb listings from the command line
5
+ Project-URL: Homepage, https://github.com/Olaf-s-World/airbnb-search
6
+ Project-URL: Repository, https://github.com/Olaf-s-World/airbnb-search
7
+ Author-email: Olaf <olaf.bot@agentmail.to>
8
+ License: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.8
20
+ Requires-Dist: requests>=2.25.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # airbnb-search šŸ 
24
+
25
+ Search Airbnb listings from the command line. No API key required.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install airbnb-search
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ### Command Line
36
+
37
+ ```bash
38
+ # Basic search
39
+ airbnb-search "Steamboat Springs, CO"
40
+
41
+ # With dates and filters
42
+ airbnb-search "Winter Park, CO" --checkin 2026-02-27 --checkout 2026-03-01 --max-price 400
43
+
44
+ # JSON output
45
+ airbnb-search "Denver, CO" --format json
46
+ ```
47
+
48
+ ### Python API
49
+
50
+ ```python
51
+ from airbnb_search import search_airbnb, parse_listings
52
+
53
+ # Search
54
+ data = search_airbnb(
55
+ query="Steamboat Springs, CO",
56
+ checkin="2026-02-27",
57
+ checkout="2026-03-01",
58
+ max_price=500
59
+ )
60
+
61
+ # Parse results
62
+ result = parse_listings(data)
63
+
64
+ for listing in result['listings']:
65
+ print(f"{listing['name']} - {listing['total_price']}")
66
+ print(f" {listing['url']}")
67
+ ```
68
+
69
+ ## Features
70
+
71
+ - šŸ” Search by location, dates, price range, and bedrooms
72
+ - šŸ’° Get actual total prices (not per-night)
73
+ - ⭐ See ratings, reviews, and superhost status
74
+ - šŸ”— Direct links to listings
75
+ - šŸ“Š Table or JSON output
76
+ - šŸš€ No API key required
77
+
78
+ ## Options
79
+
80
+ | Flag | Description |
81
+ |------|-------------|
82
+ | `--checkin`, `-i` | Check-in date (YYYY-MM-DD) |
83
+ | `--checkout`, `-o` | Check-out date (YYYY-MM-DD) |
84
+ | `--min-price` | Minimum price |
85
+ | `--max-price` | Maximum price |
86
+ | `--min-bedrooms` | Minimum bedrooms |
87
+ | `--limit` | Max results (default: 50) |
88
+ | `--format`, `-f` | Output format: table or json |
89
+
90
+ ## License
91
+
92
+ MIT
93
+
94
+ ---
95
+
96
+ Made with 🌿 by [Olaf](https://olafs-world.vercel.app)
@@ -0,0 +1,8 @@
1
+ airbnb_search/__init__.py,sha256=eq0XvTHiJtoX5GsLQrPH-WYWLYVcyU30-X_gDwjTOcQ,196
2
+ airbnb_search/cli.py,sha256=ng1KDwFyDrBS_L9rP0iaRHVSR-ROzrBekk-QriS6DVA,2754
3
+ airbnb_search/search.py,sha256=srX-32KzMArz8iu3GQwlhRN0jQQqdeC4Q8WQD7AKW84,5158
4
+ airbnb_search-0.1.0.dist-info/METADATA,sha256=VTPBOvqEsh_8_ltMfqeRI-gr0_cph0Ih7Tab1BuDKd4,2380
5
+ airbnb_search-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
+ airbnb_search-0.1.0.dist-info/entry_points.txt,sha256=5KWXCDDATfUjo78tWbAi5KaLk98oP5ns9yb_WpO2dFQ,57
7
+ airbnb_search-0.1.0.dist-info/licenses/LICENSE,sha256=R6wp-QnWz5hcOS9xs_DAAzChQm-ir9s5IQyVsVRXzz4,1061
8
+ airbnb_search-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ airbnb-search = airbnb_search.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Olaf
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.