├── .gitignore ├── LICENSE ├── README.md ├── setup.py └── zillow_api ├── __init__.py ├── __version__.py ├── client.py └── default_headers.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | test.py 132 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Scrapeit Cloud 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## What is Zillow API 2 | 3 | Zillow is a large online real estate marketplace where you can find all properties for sale or rent. Using the Zillow API or no-code [Zillow scraper](https://scrape-it.cloud/scrapers/zillow), you can connect to this vast database and retrieve real estate listings based on specific search parameters. 4 | 5 | Using the Zillow data API, you can collect up-to-date real estate data without worrying about blockings, rotating proxies, and other difficulties you might encounter in the development process. 6 | 7 | It makes it easy to get data such as a full address, coordinates (longitude and latitude), price, property description, and many other data characterizing the features of the property, such as the number of bedrooms and bathrooms. 8 | 9 | ## Install 10 | 11 | `pip install zillow-api-s` 12 | 13 | ## API Key 14 | 15 | To use the Zillow API, you need an API key. You can get an API key and some credits for free by signing up on the [Scrape-It.Cloud](https://scrape-it.cloud/). 16 | 17 | ## Using 18 | 19 | To understand how to use Zillow API, look at this Zillow API example: 20 | 21 | ```python 22 | from zillow_api import ZillowAPI 23 | 24 | zillow_api_client = ZillowAPI("INSERT_YOUR_API_KEY") 25 | 26 | search_result = zillow_api_client.search( 27 | params={ 28 | "keyword": "new york, ny", 29 | "type": "forSale", 30 | "price[min]": 1000000, 31 | "price[max]": 2000000, 32 | "homeTypes": ["house", "apartment"] 33 | } 34 | ) 35 | 36 | print(search_result) 37 | ``` 38 | 39 | In the Zillow API, there are both required and optional request parameters that you can use to customize your search. Here's an overview of the difference between the two: 40 | 41 | 1. Required Parameters: 42 | - `keyword` (string): This parameter is required and is used to specify the keyword used to search for listings. It represents the search query or location you want to retrieve listings for. 43 | - `type` (enum): This parameter is required and determines the type of listing you want to retrieve. The possible values are: forSale, forRent, or sold. 44 | 45 | 2. Optional Parameters: 46 | - `sort` (enum): This parameter allows you to specify the sorting option for the search results. It is an optional parameter, and the possible values include various sorting criteria such as verifiedSource, homesForYou, priceHighToLow, and more. 47 | - `price` (object): This parameter allows you to filter listings based on the price range. It is an optional parameter consisting of min and max values representing the minimum and maximum price of the listing. 48 | - `beds` (object): This parameter enables you to filter listings based on the number of bedrooms. It is optional and includes min and max values to define the minimum and maximum number of bedrooms. 49 | - `baths` (object): Similar to beds, this parameter allows you to filter listings based on the number of bathrooms. It is optional and includes min and max values to define the minimum and maximum number of bathrooms. 50 | - Several other optional parameters are available, such as yearBuilt, lotSize, squareFeet, homeTypes, etc. 51 | 52 | You can narrow your search criteria using these additional options and get listings that meet your requirements. For example, to include or exclude certain features, set price ranges, specify the number of bedrooms or bathrooms, and more. 53 | 54 | You can also retrieve data for a specific property using the following function: 55 | 56 | ```python 57 | from zillow_api import ZillowAPI 58 | 59 | zillow_api_client = ZillowAPI("INSERT_YOUR_API_KEY") 60 | 61 | property_result = zillow_api_client.property( 62 | params={ 63 | "url": "https://www.zillow.com/homedetails/301-E-79th-St-APT-23S-New-York-NY-10075/31543731_zpid/" 64 | } 65 | ) 66 | 67 | print(property_result) 68 | ``` 69 | 70 | You can learn more about the additional options and response format on [the documentation page](https://docs.scrape-it.cloud/zillow-api/listing). 71 | 72 | ## Zillow API use cases 73 | 74 | The Zillow API has many use cases for developers, businesses, and individuals in the real estate industry. For example, you can use the Zillow API to gather data on real estate trends, market values, and property information. 75 | 76 | You can also use the Zillow API to provide location-based services, such as nearby amenities, schools, transportation options, etc. This can help people make informed decisions about the suitability of a property based on its surroundings. 77 | 78 | Using the Zillow API to gain insights into market trends, demographics, and real estate statistics is useful for market research firms. 79 | 80 | ## Zillow Python API for Real Estate Scraping 81 | 82 | Python is one of the most popular programming languages for web scraping and data processing. Therefore, you can create a multifunctional tool for working and processing real estate data using the Python Zillow API. 83 | 84 | ## Proxy or Zillow API 85 | 86 | If you need to collect real estate data from Zillow and you are writing your own scraper, you have two options: 87 | 88 | 1. Research the structure of Zillow and write your own algorithm to collect data. Here, you will need to use a proxy to avoid blocking. You may also need to plug in captcha services. 89 | 90 | 2. Use Zillow API for Python. You don't need to use proxies here since API already uses them. 91 | 92 | Everyone decides which option is more suitable for him based on the tasks of the project and its requirements. 93 | 94 | If you want to know more about Zillow scraping, you can read our article about [Zillow scraping in Python](https://scrape-it.cloud/blog/scraping-zillow-using-python). 95 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from setuptools import setup 4 | 5 | about = {} 6 | here = os.path.abspath(os.path.dirname(__file__)) 7 | with open(os.path.join(here, 'zillow_api', '__version__.py'), 'r', encoding='utf-8') as f: 8 | exec(f.read(), about) 9 | 10 | setup( 11 | name='zillow-api-s', 12 | version=about['__version__'], 13 | url='https://github.com/Scrapeit-Cloud/zillow-api-python', 14 | description='Real-Time Zillow API', 15 | long_description=open('README.md').read(), 16 | long_description_content_type='text/markdown', 17 | author='Roman Milyushkevich', 18 | author_email='roman@scrape-it.cloud', 19 | maintainer='Roman Milyushkevich', 20 | maintainer_email='roman@scrape-it.cloud', 21 | license='MIT', 22 | packages=['zillow_api'], 23 | classifiers=[ 24 | 'License :: OSI Approved :: MIT License', 25 | 'Programming Language :: Python', 26 | 'Programming Language :: Python :: 3', 27 | 'Programming Language :: Python :: 3.7', 28 | 'Programming Language :: Python :: 3.8', 29 | 'Programming Language :: Python :: 3.9', 30 | 'Programming Language :: Python :: 3.10', 31 | 'Programming Language :: Python :: 3.11', 32 | 'Topic :: Software Development :: Libraries :: Python Modules', 33 | ], 34 | python_requires='>=3.6', 35 | install_requires=['requests'], 36 | ) 37 | -------------------------------------------------------------------------------- /zillow_api/__init__.py: -------------------------------------------------------------------------------- 1 | __all__ = ['ZillowAPI'] 2 | 3 | from zillow_api.client import ZillowAPI 4 | -------------------------------------------------------------------------------- /zillow_api/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.0.1' 2 | -------------------------------------------------------------------------------- /zillow_api/client.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from urllib.parse import urlencode 3 | 4 | ZILLOW_LISTING_API = 'https://api.scrape-it.cloud/zillow/listing' 5 | ZILLOW_PROPERTY_API = 'https://api.scrape-it.cloud/zillow/property' 6 | 7 | class ZillowAPI: 8 | def __init__(self, apiKey=None): 9 | if apiKey is None: 10 | raise ValueError('API Key is not provided') 11 | 12 | self.apiKey = apiKey 13 | 14 | def handleErrors(self, result, statusCode): 15 | if "status" in result and result['status'] and result['status'] == 'error' and 'message' in result: 16 | raise ValueError(result['message']) 17 | 18 | if statusCode == 403: 19 | raise ValueError("You don't have enough API credits to perform this request") 20 | 21 | if statusCode == 401: 22 | raise ValueError('Invalid API Key') 23 | 24 | if statusCode == 429: 25 | raise ValueError('You reached concurrency limit') 26 | 27 | if 'errors' in result and len(result['errors']) > 0: 28 | error = ValueError('Validation error') 29 | error.validation_errors = result['errors'] 30 | raise error 31 | 32 | if 'requestMetadata' not in result: 33 | raise ValueError('Invalid response') 34 | 35 | if "status" in result['requestMetadata'] and result['requestMetadata']['status'] == 'error': 36 | raise ValueError('Invalid response') 37 | 38 | def search(self, params): 39 | url = f"{ZILLOW_LISTING_API}?{urlencode(params, doseq=True)}" 40 | 41 | headers = { 42 | 'x-api-key': self.apiKey, 43 | } 44 | 45 | requestParams = { 46 | 'source': 'python_sdk' 47 | } 48 | 49 | response = requests.get(url, headers=headers, params=requestParams) 50 | result = response.json() 51 | 52 | self.handleErrors(result, response.status_code) 53 | 54 | if result['requestMetadata']['status'] == 'ok': 55 | return result 56 | 57 | return result 58 | 59 | def property(self, params): 60 | url = f"{ZILLOW_PROPERTY_API}?{urlencode(params)}" 61 | 62 | headers = { 63 | 'x-api-key': self.apiKey, 64 | } 65 | 66 | requestParams = { 67 | 'source': 'python_sdk' 68 | } 69 | 70 | response = requests.get(url, headers=headers, params=requestParams) 71 | result = response.json() 72 | 73 | self.handleErrors(result, response.status_code) 74 | 75 | if result['requestMetadata']['status'] == 'ok': 76 | return result 77 | 78 | return result -------------------------------------------------------------------------------- /zillow_api/default_headers.py: -------------------------------------------------------------------------------- 1 | from .__version__ import __version__ 2 | 3 | # Add User-Agent identifying sdk 4 | default_headers = {"User-Agent": f"ScrapeitCloudZillowSDK-Python/{__version__}"} 5 | --------------------------------------------------------------------------------