Skip to content

Commit 3e9d025

Browse files
authored
Merge pull request #84 from ParclLabs/refactor
Refactor
2 parents 36904a3 + 10e7ca8 commit 3e9d025

22 files changed

+932
-846
lines changed

Pipfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ numpy = "*"
1111
[dev-packages]
1212
parcllabs = {path = ".", editable = true}
1313
pytest = ">=8"
14-
requests-mock = ">=1"
15-
asynctest = ">=0.13"
16-
pytest_asyncio = ">=0.15"
1714
ruff = "*"
1815

1916
[requires]
20-
python_version = "==3.12"
17+
python_version = "3.11.11"

Pipfile.lock

Lines changed: 300 additions & 358 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 49 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,35 @@
33
![GitHub Tag](https://img.shields.io/github/v/tag/ParclLabs/parcllabs-python)
44
![PyPI - Downloads](https://img.shields.io/pypi/dm/parcllabs)
55
<!-- readme header end -->
6-
## **Welcome to the Parcl Labs Python SDK**
6+
7+
# Parcl Labs Python SDK
78

89
**We're on a mission to create the world's best API developer experience and community for housing data.**
910

1011
Our SDK is designed to supercharge your API experience and accelerate your time to insight. It enables you to efficiently pull the data you need, analyze it, and visualize your findings.
1112

12-
<!-- readme header split -->
13-
## Parcl Labs Data Overview
14-
15-
The Parcl Labs API provides **instant insights into the U.S. housing market**, delivering data on housing supply, sales, listings, rentals, investor activities, and market trends.
13+
## Table of Contents
14+
- [Data Overview](#parcl-labs-data-overview)
15+
- [Getting Started](#getting-started)
16+
- [Services](#services)
17+
- [Search](#search)
18+
- [Rental Market Metrics](#rental-market-metrics)
19+
- [For Sale Market Metrics](#for-sale-market-metrics)
20+
- [Market Metrics](#market-metrics)
21+
- [New Construction Metrics](#new-construction-metrics)
22+
- [Investor Metrics](#investor-metrics)
23+
- [Portfolio Metrics](#portfolio-metrics)
24+
- [Price Feeds](#price-feeds)
25+
- [Property](#property)
26+
- [Property Address Search](#property-address-search)
27+
- [Property Search V2](#property-search-v2)
28+
- [Account Info](#account-info)
29+
- [Cookbook](#cookbook)
1630

31+
<!-- readme header split -->
32+
## Parcl Labs Data Overview <a id="parcl-labs-data-overview"></a>
1733

34+
The Parcl Labs API provides **instant insights into the U.S. housing market**, delivering data on housing supply, sales, listings, rentals, investor activities, and market trends.
1835

1936
_The most complete picture of US residential real estate_
2037

@@ -23,26 +40,18 @@ _The most complete picture of US residential real estate_
2340
| **Property Types** | **🏘️ All Residential Assets:**<br>✅ Single Family<br>✅ Townhouses<br>✅ Condos<br>✅ Other |
2441
| **Markets** | **🇺🇸 Complete National Coverage, 70k+ Unique Markets at Any Level of Granularity:**<br>✅ Regions<br>✅ States<br>✅ Metros<br>✅ Cities<br>✅ Counties<br>✅ Towns<br>✅ Zips<br>✅ Census Places |
2542
| **Housing Events** | **🔄 The Full Property Lifecycle:**<br>✅ Sales<br>✅ For Sale Listings<br>✅ Rentals |
26-
2743
<!-- readme header end -->
28-
### Cookbook
2944

30-
We maintain a repository of examples that demonstrate how to use the Parcl Labs API for analysis. You can find the examples in the [Parcl Labs Cookbook](https://github.com/parcllabs/parcllabs-cookbook)
45+
## Cookbook <a id="cookbook"></a>
3146

32-
## Premium Users
33-
Are you a premium user? See the [premium features](#premium-features) section for more information on how to access premium features including:
34-
- Access all homes for Invitation Homes, American Homes 4 Rent, and other large investors
35-
- Access national, unit level data with full event cycles (rentals, listings, sales)
36-
- Access `turbo_mode` for faster data retrieval
47+
We maintain a repository of examples that demonstrate how to use the Parcl Labs API for analysis. You can find the examples in the [Parcl Labs Cookbook](https://github.com/parcllabs/parcllabs-cookbook)
3748

38-
## Getting Started
49+
## Getting Started <a id="getting-started"></a>
3950

4051
### Step 1. Sign Up for an API Key
4152

4253
To use the Parcl Labs API, you need an API key. To get an API key, sign up at [ParclLabs](https://dashboard.parcllabs.com/signup). In the subsequent examples, the API key is stored in the `PARCLLABS_API_KEY` environment variable.
4354

44-
45-
4655
### Step 2. Installation
4756

4857
You can install the package via pip:
@@ -65,7 +74,18 @@ api_key = os.getenv('PARCL_LABS_API_KEY')
6574
client = ParclLabsClient(api_key)
6675
```
6776

68-
#### Search
77+
#### Num Workers
78+
79+
The `num_workers` parameter is used to specify the number of workers to use for parallel requests. The default is None, which translates to `min(32, (os.cpu_count() or 1) + 4)`. See [docs](https://github.com/python/cpython/blob/dcc3eaef98cd94d6cb6cb0f44bd1c903d04f33b1/Lib/concurrent/futures/thread.py#L137) for more details.
80+
81+
```python
82+
client = ParclLabsClient(api_key, num_workers=20)
83+
```
84+
85+
## Services <a id="services"></a>
86+
87+
### Search <a id="search"></a>
88+
6989
Search is your entry point into finding one or many of over 70,000 markets in the United States. You can search for markets by `name`, `state`, `region`, `fips`, or `zip code`. You can also search for markets by their unique `parcl_id`.
7090

7191
##### Search Markets
@@ -84,11 +104,7 @@ top_market_parcl_ids = markets['parcl_id'].tolist()
84104
# 2900078 USA 31080 None Los Angeles-Long Beach-Anaheim, Ca None None CBSA 13111917 89105 0 1 1 1
85105
```
86106

87-
#### Services
88-
89-
Services are the core of the Parcl Labs API. They provide access to a wide range of data and analytics on the housing market. The services are divided into the following categories: `Price Feeds`, `Rental Market Metrics`, `For Sale Market Metrics`, `Market Metrics`, `Investor Metrics`, `Portfolio Metrics` and `Property`.
90-
91-
#### Rental Market Metrics
107+
### Rental Market Metrics <a id="rental-market-metrics"></a>
92108

93109
##### Gross Yield
94110
Gets the percent gross yield for a specified `parcl_id`. At the market level, identified by `parcl_id`, gross yield is calculated by dividing the annual median rental income—derived from multiplying the monthly median new rental listing price by 12—by its median new listings for sale price.
@@ -99,7 +115,6 @@ Gets the number of rental units, total units, and percent rental unit concentrat
99115
##### New Listings for Rent Rolling Counts
100116
Gets weekly updated rolling counts of newly listed for rent properties, segmented into 7, 30, 60, and 90 day periods ending on a specified date, based on a given `parcl_id`.
101117

102-
###### Get all rental market metrics
103118
```python
104119
start_date = '2024-04-01'
105120
end_date = '2024-04-01'
@@ -121,7 +136,7 @@ rentals_new_listings_rolling_counts = client.rental_market_metrics.new_listings_
121136
)
122137
```
123138

124-
#### For Sale Market Metrics
139+
### For Sale Market Metrics <a id="for-sale-market-metrics"></a>
125140

126141
##### New Listings Rolling Counts
127142
Gets weekly updated rolling counts of newly listed for sale properties, segmented into 7, 30, 60, and 90 day periods ending on a specified date, based on a given `parcl_id`.
@@ -132,7 +147,6 @@ Gets the weekly updated current count of total inventory listed on market for sa
132147
##### For Sale Inventory Price Changes
133148
Gets weekly updated metrics on the price behavior of current for sale inventory, based on a specified `parcl_id`. Available metrics include the count of price changes, count of price drops, median days between price changes, median price change, and the percentage of inventory with price changes. The data series for the for sale inventory metrics begins on September 1, 2022 (2022-09-01).
134149

135-
###### Get all for sale market metrics
136150
```python
137151
start_date = '2024-04-01'
138152
end_date = '2024-04-01'
@@ -158,7 +172,7 @@ for_sale_inventory_price_changes = client.for_sale_market_metrics.for_sale_inven
158172
)
159173
```
160174

161-
#### Market Metrics
175+
### Market Metrics <a id="market-metrics"></a>
162176

163177
##### Housing Event Counts
164178
Gets monthly counts of housing events, including sales, new sale listings, and new rental listings, based on a specified `parcl_id`.
@@ -175,8 +189,6 @@ Gets monthly statistics on the physical attributes of properties involved in hou
175189
##### All Cash
176190
Gets monthly counts of all cash transactions and their percentage share of total sales, based on a specified `parcl_id`.
177191

178-
179-
###### Get all market metrics
180192
```python
181193
start_date = '2024-01-01'
182194
end_date = '2024-04-01'
@@ -212,15 +224,14 @@ results_all_cash = client.market_metrics.all_cash.retrieve(
212224
)
213225
```
214226

215-
#### New Construction Metrics
227+
### New Construction Metrics <a id="new-construction-metrics"></a>
216228

217229
##### Housing Event Counts
218230
Gets monthly counts of new construction housing events, including sales, new for sale listings, and new rental listings, based on a specified `parcl_id`.
219231

220232
##### Housing Event Prices
221233
Gets monthly median prices for new construction housing events, including sales, new for sale listings, and new rental listings, based on a specified `parcl_id`.
222234

223-
###### Get all new construction metrics
224235
```python
225236
start_date = '2024-01-01'
226237
end_date = '2024-04-01'
@@ -238,7 +249,7 @@ results_new_construction_housing_event_counts = client.new_construction_metrics.
238249
)
239250
```
240251

241-
#### Investor Metrics
252+
### Investor Metrics <a id="investor-metrics"></a>
242253

243254
##### Housing Event Counts
244255
Gets monthly counts of investor housing events, including acquisitions, dispositions, new sale listings, and new rental listings, based on a specified `parcl_id`.
@@ -255,7 +266,6 @@ Gets counts of investor-owned properties and their corresponding percentage owne
255266
##### Housing Event Prices
256267
Gets monthly median prices for investor housing events, including acquisitions, dispositions, new sale listings, and new rental listings, based on a specified `parcl_id`.
257268

258-
###### Get all investor metrics
259269
```python
260270
start_date = '2024-01-01'
261271
end_date = '2024-04-01'
@@ -291,22 +301,18 @@ results = client.investor_metrics.housing_event_prices.retrieve(
291301
)
292302
```
293303

294-
#### Portfolio Metrics
304+
### Portfolio Metrics <a id="portfolio-metrics"></a>
295305

296306
##### Single Family Housing Event Counts
297-
298307
Gets monthly counts of investor-owned single family property housing events, segmented by portfolio size, for a specified `parcl_id`. Housing events include acquisitions, dispositions, new for sale listings, and new rental listings.
299308

300309
##### Single Family Housing Stock Ownership
301-
302310
Gets counts of investor-owned single family properties and their corresponding percentage of the total single family housing stock, segmented by portfolio size, for a specified `parcl_id`. The data series for portfolio metrics begins on March 1, 2024 (2024-03-01).
303311

304312
##### New Listings for Sale Rolling Counts
305-
306313
Gets counts of investor-owned single family properties and their corresponding percentage of the total single family housing stock, segmented by portfolio size, for a specified `parcl_id`. The data series for portfolio metrics begins on April 15, 2024 (2024-04-15).
307314

308315
##### New Listings for Rent Rolling Counts
309-
310316
Gets weekly updated rolling counts of investor-owned single family properties newly listed for rent, segmented by portfolio size, and their corresponding percentage share of the total single family for rent listings market. These metrics are divided into 7, 30, 60, and 90 day periods ending on a specified date, based on a given `parcl_id`. The data series for portfolio metrics begins on April 22, 2024 (2024-04-22).
311317

312318
```python
@@ -331,7 +337,8 @@ results = client.portfolio_metrics.sf_new_listings_for_rent_rolling_counts.retri
331337
)
332338
```
333339

334-
#### Price Feeds
340+
### Price Feeds <a id="price-feeds"></a>
341+
335342
The Parcl Labs Price Feed (PLPF) is a daily-updated, real-time indicator of residential real estate prices, measured by price per square foot, across select US markets.
336343

337344
The Price Feeds category allows you to access our daily-updated PLPF and derivative metrics, such as volatility.
@@ -372,21 +379,9 @@ price_feed_volatility = client.price_feed.volatility.retrieve(
372379
start_date=start_date,
373380
end_date=end_date
374381
)
375-
376-
# want to save to csv? Use .to_csv method as follow:
377-
# price_feeds.to_csv('price_feeds.csv', index=False)
378-
# rental_price_feeds.to_csv('rental_price_feeds.csv', index=False)
379-
# price_feed_volatility.to_csv('price_feed_volatility.csv', index=False)
380382
```
381383

382-
### Premium Features
383-
A premium Parcl Labs API key unlocks several critical features. This includes:
384-
- Access to our unit level, full event lifecycle data
385-
- Access to `turbo_mode` for faster data retrieval
386-
387-
You can register for a premium Parcl Labs API key through your [account dashboard](https://dashboard.parcllabs.com/).
388-
389-
#### Property
384+
### Property <a id="property"></a>
390385

391386
##### Property Search Markets
392387
Gets a list of unique identifiers (parcl_property_id) for units that correspond to specific markets or parameters defined by the user. The parcl_property_id is key to navigating the Parcl Labs API, serving as the core mechanism for retrieving unit-level information.
@@ -459,8 +454,8 @@ rental_events = client.property.events.retrieve(
459454
)
460455
```
461456

457+
### Property Address Search <a id="property-address-search"></a>
462458

463-
#### Property Address Search
464459
Pass in a list of addresses -- `address, unit, city, state_abbreviation, zip_code, source_id` -- and receive the associated `parcl_property_id`, if there is a match. `unit` and `source_id` are optional fields.
465460

466461
```python
@@ -485,8 +480,8 @@ addresses = client.property_address.search.retrieve(
485480
)
486481
```
487482

483+
### Property Search V2 <a id="property-search-v2"></a>
488484

489-
#### Property Search V2
490485
Gets a list of unique properties and their associated metadata and events based on a set of filters. Use one of three search methods:
491486
1. `parcl_ids`
492487
2. `parcl_property_ids`
@@ -517,18 +512,8 @@ results, filter_data = client.property_v2.search.retrieve(
517512
)
518513
```
519514

515+
### Account Info <a id="account-info"></a>
520516

521-
##### Turbo Mode
522-
Turbo mode is a premium feature that allows you to retrieve data faster. To enable turbo mode, set the `turbo_mode` parameter to `True` when creating an instance of the `ParclLabsClient` class.
523-
524-
```python
525-
client = ParclLabsClient(api_key, turbo_mode=True)
526-
```
527-
528-
This will enable turbo mode for all subsequent API calls which is a smart switch to route API calls through more efficient, premium endpoints designed for bulk data retrieval.
529-
530-
531-
##### Account Info
532517
Monitor your API usage and quota limits by calling the `account()` method in the `ParclLabsClient` class.
533518
```python
534519
client = ParclLabsClient(api_key)

parcllabs/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "1.13.1"
1+
VERSION = "1.14.0"

parcllabs/common.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,13 @@
11
from parcllabs.enums import (
2-
EntityNames,
3-
EventTypes,
4-
LocationTypes,
5-
PortfolioSizes,
6-
PropertyTypes,
7-
PropertyTypesUnit,
82
RequestMethods,
93
ResponseColumns,
10-
SortByParams,
11-
SortOrder,
12-
USRegions,
134
USStateAbbreviations,
14-
USStateFIPSCodes,
155
get_enum_values,
166
)
177

18-
VALID_US_REGIONS = get_enum_values(USRegions)
198
VALID_US_STATE_ABBREV = get_enum_values(USStateAbbreviations)
20-
VALID_US_STATE_FIPS_CODES = get_enum_values(USStateFIPSCodes)
21-
VALID_SORT_BY = get_enum_values(SortByParams)
22-
VALID_SORT_ORDER = get_enum_values(SortOrder)
23-
VALID_EVENT_TYPES = get_enum_values(EventTypes)
24-
VALID_ENTITY_NAMES = get_enum_values(EntityNames)
25-
VALID_PROPERTY_TYPES = get_enum_values(PropertyTypes)
26-
VALID_PORTFOLIO_SIZES = get_enum_values(PortfolioSizes)
27-
VALID_LOCATION_TYPES = get_enum_values(LocationTypes)
28-
VALID_PROPERTY_TYPES_UNIT_SEARCH = get_enum_values(PropertyTypesUnit)
299

3010
ID_COLUMNS = [ResponseColumns.PARCL_ID.value, ResponseColumns.PARCL_PROPERTY_ID.value]
31-
3211
DATE_COLUMNS = [ResponseColumns.DATE.value, ResponseColumns.EVENT_DATE.value]
3312

3413
DELETE_FROM_OUTPUT = [

parcllabs/parcllabs_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def __init__(
4343
api_key: str,
4444
api_url: str = api_base,
4545
limit: int | None = None,
46-
turbo_mode: bool = False,
4746
num_workers: int | None = None,
4847
) -> None:
4948
if not api_key:
@@ -54,7 +53,6 @@ def __init__(
5453
self.account_info = {"est_session_credits_used": 0}
5554
self.num_workers = num_workers
5655
self.limit = limit
57-
self.turbo_mode = turbo_mode
5856

5957
self._initialize_services()
6058

0 commit comments

Comments
 (0)