forked from reteps/redfin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch to build/ dist/ for versioning instead of git
- Loading branch information
Showing
17 changed files
with
239 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# file GENERATED by distutils, do NOT edit | ||
README | ||
setup.cfg | ||
setup.py | ||
redfin/__init__.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from redfin.redfin import Redfin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import requests | ||
import json | ||
|
||
|
||
class Redfin: | ||
def __init__(self): | ||
self.base = 'https://redfin.com/stingray/' | ||
self.user_agent_header = { | ||
'user-agent': 'redfin' | ||
} | ||
|
||
def meta_property(self, url, kwargs, page=False): | ||
if page: | ||
kwargs['pageType'] = 3 | ||
return self.meta_request('api/home/details/' + url, { | ||
'accessLevel': 1, | ||
**kwargs | ||
}) | ||
|
||
def meta_request(self, url, kwargs): | ||
response = requests.get( | ||
self.base + url, params=kwargs, headers=self.user_agent_header) | ||
response.raise_for_status() | ||
return json.loads(response.text[4:]) | ||
|
||
# Url Requests | ||
|
||
def initial_info(self, url, **kwargs): | ||
return self.meta_request('api/home/details/initialInfo', {'path': url, **kwargs}) | ||
|
||
def page_tags(self, url, **kwargs): | ||
return self.meta_request('api/home/details/v1/pagetagsinfo', {'path': url, **kwargs}) | ||
|
||
def primary_region(self, url, **kwargs): | ||
return self.meta_request('api/home/details/primaryRegionInfo', {'path': url, **kwargs}) | ||
|
||
# Search | ||
def search(self, query, **kwargs): | ||
return self.meta_request('do/location-autocomplete', {'location': query, 'v': 2, **kwargs}) | ||
|
||
# Property ID Requests | ||
def below_the_fold(self, property_id, **kwargs): | ||
return self.meta_property('belowTheFold', {'propertyId': property_id, **kwargs}, page=True) | ||
|
||
def hood_photos(self, property_id, **kwargs): | ||
return self.meta_request('api/home/details/hood-photos', {'propertyId': property_id, **kwargs}) | ||
|
||
def more_resources(self, property_id, **kwargs): | ||
return self.meta_request('api/home/details/moreResourcesInfo', {'propertyId': property_id, **kwargs}) | ||
|
||
def page_header(self, property_id, **kwargs): | ||
return self.meta_request('api/home/details/homeDetailsPageHeaderInfo', {'propertyId': property_id, **kwargs}) | ||
|
||
def property_comments(self, property_id, **kwargs): | ||
return self.meta_request('api/v1/home/details/propertyCommentsInfo', {'propertyId': property_id, **kwargs}) | ||
|
||
def building_details_page(self, property_id, **kwargs): | ||
return self.meta_request('api/building/details-page/v1', {'propertyId': property_id, **kwargs}) | ||
|
||
def owner_estimate(self, property_id, **kwargs): | ||
return self.meta_request('api/home/details/owner-estimate', {'propertyId': property_id, **kwargs}) | ||
|
||
def claimed_home_seller_data(self, property_id, **kwargs): | ||
return self.meta_request('api/home/details/claimedHomeSellerData', {'propertyId': property_id, **kwargs}) | ||
|
||
def cost_of_home_ownership(self, property_id, **kwargs): | ||
return self.meta_request('do/api/costOfHomeOwnershipDetails', {'propertyId': property_id, **kwargs}) | ||
|
||
# Listing ID Requests | ||
def floor_plans(self, listing_id, **kwargs): | ||
return self.meta_request('api/home/details/listing/floorplans', {'listingId': listing_id, **kwargs}) | ||
|
||
def tour_list_date_picker(self, listing_id, **kwargs): | ||
return self.meta_request('do/tourlist/getDatePickerData', {'listingId': listing_id, **kwargs}) | ||
|
||
# Table ID Requests | ||
|
||
def shared_region(self, table_id, **kwargs): | ||
return self.meta_request('api/region/shared-region-info', {'tableId': table_id, 'regionTypeId': 2, 'mapPageTypeId': 1, **kwargs}) | ||
|
||
# Property Requests | ||
|
||
def similar_listings(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('similars/listings', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def similar_sold(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('similars/solds', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def nearby_homes(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('nearbyhomes', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def above_the_fold(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('aboveTheFold', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def property_parcel(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('propertyParcelInfo', {'propertyId': property_id, 'listingId': listing_id, **kwargs}, page=True) | ||
|
||
def activity(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('activityInfo', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def customer_conversion_info_off_market(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('customerConversionInfo/offMarket', {'propertyId': property_id, 'listingId': listing_id, **kwargs}, page=True) | ||
|
||
def rental_estimate(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('rental-estimate', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def avm_historical(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('avmHistoricalData', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def info_panel(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('mainHouseInfoPanelInfo', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def descriptive_paragraph(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('descriptiveParagraph', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def avm_details(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('avm', {'propertyId': property_id, 'listingId': listing_id, **kwargs}) | ||
|
||
def tour_insights(self, property_id, listing_id, **kwargs): | ||
return self.meta_property('tourInsights', {'propertyId': property_id, 'listingId': listing_id, **kwargs}, page=True) | ||
|
||
def stats(self, property_id, listing_id, region_id, **kwargs): | ||
return self.meta_property('stats', {'regionId': region_id, 'propertyId': property_id, 'listingId': listing_id, 'regionTypeId': 2, **kwargs}) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
Metadata-Version: 2.1 | ||
Name: redfin | ||
Version: 0.1.1 | ||
Summary: A python wrapper around the unofficial redfin API. | ||
Home-page: https://github.com/reteps/redfin | ||
Author: Peter Stenger | ||
Author-email: [email protected] | ||
License: MIT | ||
Description: # Python-Redfin | ||
|
||
A wrapper around redfin's unofficial API. Anything on the redfin site can be accessed through this module without screen scraping. | ||
### Installation | ||
|
||
``` | ||
$ python3 -m pip install redfin | ||
``` | ||
|
||
### Usage | ||
|
||
```python3 | ||
|
||
from redfin import Redfin | ||
|
||
client = Redfin() | ||
|
||
address = '4544 Radnor St, Detroit Michigan' | ||
|
||
response = client.search(address) | ||
url = response['payload']['exactMatch']['url'] | ||
initial_info = client.initial_info(url) | ||
|
||
property_id = initial_info['payload']['propertyId'] | ||
listing_id = initial_info['payload']['listingId'] | ||
|
||
mls_data = client.below_the_fold(property_id, listing_id) | ||
``` | ||
|
||
### Documentation | ||
|
||
See the file for all functions, pop open requests on redfin to see which one you want. | ||
|
||
Keywords: redfin,api,wrapper | ||
Platform: UNKNOWN | ||
Classifier: Development Status :: 3 - Alpha | ||
Classifier: Intended Audience :: Developers | ||
Classifier: Topic :: Software Development :: Build Tools | ||
Classifier: License :: OSI Approved :: MIT License | ||
Classifier: Programming Language :: Python :: 3 | ||
Classifier: Programming Language :: Python :: 3.4 | ||
Classifier: Programming Language :: Python :: 3.5 | ||
Classifier: Programming Language :: Python :: 3.6 | ||
Classifier: Programming Language :: Python :: 3.7 | ||
Classifier: Programming Language :: Python :: 3.8 | ||
Description-Content-Type: text/markdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
README.md | ||
setup.py | ||
redfin/__init__.py | ||
redfin/redfin.py | ||
redfin.egg-info/PKG-INFO | ||
redfin.egg-info/SOURCES.txt | ||
redfin.egg-info/dependency_links.txt | ||
redfin.egg-info/requires.txt | ||
redfin.egg-info/top_level.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
redfin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
requests | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
from distutils.core import setup | ||
import setuptools | ||
|
||
with open("README.md", "r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
setup( | ||
name = 'redfin', # How you named your package folder (MyLib) | ||
packages = ['redfin'], # Chose the same as "name" | ||
version = '0.1', # Start with a small number and increase it with every change you make | ||
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository | ||
description = 'A python wrapper around the unofficial redfin API.', # Give a short description about your library | ||
author = 'Peter Stenger', # Type in your name | ||
author_email = '[email protected]', # Type in your E-Mail | ||
url = 'https://github.com/reteps/redfin', # Provide either the link to your github or to your website | ||
download_url = 'https://github.com/reteps/redfin/archive/0.1.tar.gz', # I explain this later on | ||
keywords = ['redfin', 'api', 'wrapper'], # Keywords that define your package best | ||
install_requires=[ # I get to this in a second | ||
'requests' | ||
name="redfin", # How you named your package folder (MyLib) | ||
version="0.1.1", # Start with a small number and increase it with every change you make | ||
license="MIT", # Chose a license from here: https://help.github.com/articles/licensing-a-repository | ||
description="A python wrapper around the unofficial redfin API.", # Give a short description about your library | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
author="Peter Stenger", # Type in your name | ||
packages=setuptools.find_packages(), | ||
author_email="[email protected]", # Type in your E-Mail | ||
url="https://github.com/reteps/redfin", # Provide either the link to your github or to your website | ||
keywords=["redfin", "api", "wrapper"], # Keywords that define your package best | ||
install_requires=["requests"], | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package | ||
"Intended Audience :: Developers", # Define that your audience are developers | ||
"Topic :: Software Development :: Build Tools", | ||
"License :: OSI Approved :: MIT License", # Again, pick a license | ||
"Programming Language :: Python :: 3", # Specify which pyhton versions that you want to support | ||
"Programming Language :: Python :: 3.4", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
], | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package | ||
'Intended Audience :: Developers', # Define that your audience are developers | ||
'Topic :: Software Development :: Build Tools', | ||
'License :: OSI Approved :: MIT License', # Again, pick a license | ||
'Programming Language :: Python :: 3', #Specify which pyhton versions that you want to support | ||
'Programming Language :: Python :: 3.4', | ||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
], | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from redfin import Redfin | ||
|
||
client = Redfin() | ||
|
||
address = '4544 Radnor St, Detroit Michigan' | ||
|
||
response = client.search(address) | ||
url = response['payload']['exactMatch']['url'] | ||
initial_info = client.initial_info(url) | ||
|
||
property_id = initial_info['payload']['propertyId'] | ||
listing_id = initial_info['payload']['listingId'] | ||
|
||
mls_data = client.below_the_fold(property_id, listing_id) | ||
print(mls_data) | ||
|