By the end of this tutorial you will have a short Python script that runs the OnTheMarket Scraper for a UK location, waits for the run to finish, and prints one line per property with its price, address, bedroom count and agent phone number. The output is JSON rows you can store, filter or load into a spreadsheet.
OnTheMarket is the UK property portal, with listings for sale and to rent. Checking one town by hand means opening search results page after page and copying prices and agent details into a sheet. This tutorial replaces that with one API call.
We use the OnTheMarket Scraper Actor (reventadata/onthemarket-scraper) from Python with the official apify-client package. The Actor reads OnTheMarket's public search pages directly, so it needs no browser and no login.
Note: OnTheMarket is a trademark of its owner. The OnTheMarket Scraper is not affiliated with, authorised by or endorsed by OnTheMarket or CoStar Group. It only describes what the tool reads.
Prerequisites
To follow this tutorial, you need:
- Python 3 installed on your machine.
- The Apify API client for Python. Install or upgrade it with:
pip install -U "apify-client~=3.0" - An Apify account and your personal API token. Copy the token from API & Integrations in the Apify Console.
Set the token as an environment variable in your terminal:
export APIFY_API_TOKEN="your_apify_token_here" No coding beyond the script below is needed.
What you'll achieve
Each dataset row is one property listing. A row carries id, url, transaction, title, address, propertyType, bedrooms, bathrooms, price, currency, priceFrequency, priceQualifier, priceDisplay, latitude, longitude, addedOrReduced, agentName, agentBranchId, agentPhone, agentUrl, keyFeatures, imageUrl, imageUrls, imageCount and searchUrl.
Example use case: list the flats for sale in London with their prices and agent phone numbers, then save the rows to a file each morning.
Step-by-step: run the Actor from Python
Step 1: Open the Actor
Open the OnTheMarket Scraper page on Apify Store. It lists the input fields and the output fields. This guide calls the Actor from Python.
Step 2: Set the input
The input has four fields you will use:
-
transaction:buyfor sale orrentfor to rent. Defaultbuy. -
propertyType:propertyfor all property types orhousesfor houses only. Defaultproperty. -
location: the location slug as it appears in an OnTheMarket search URL, for examplelondon,manchesterornewcastle-upon-tyne. -
maxItemsandmaxPages: caps on rows and result pages. The site sets 30 listings per page and a ceiling of 34 pages.
Step 3: Start the run and read the rows
Save this as onthemarket_listings.py:
import os from apify_client import ApifyClient # 1. Create the client with the token from your environment client = ApifyClient(os.environ["APIFY_API_TOKEN"]) # 2. Define the search; the field names match the Actor's input schema run_input = { "transaction": "buy", "propertyType": "property", "location": "london", "maxItems": 10, "maxPages": 1, } # 3. Start the run and wait until it finishes run = client.actor("reventadata/onthemarket-scraper").call(run_input=run_input) if run is None or run.status != "SUCCEEDED": status = run.status if run else "unknown" raise SystemExit(f"Run did not succeed (status: {status}).") # 4. Read the rows from the run's default dataset items = client.dataset(run.default_dataset_id).list_items().items print(f"Retrieved {len(items)} listings.") Run it with python3 onthemarket_listings.py. The run writes its rows to the dataset, and the script reads them back.
Step 4: Print the fields you need
Add this under the script:
for item in items: print(f"Address: {item.get('address')}") print(f" Price: {item.get('priceDisplay')}") print(f" Beds: {item.get('bedrooms')}, baths: {item.get('bathrooms')}") print(f" Agent: {item.get('agentName')} {item.get('agentPhone') or ''}".rstrip()) print(f" Listing: {item.get('url')}") print("-" * 50) Fields can be null on some listings. Coordinates, key features and bedroom counts are the ones most often empty, so the get calls above avoid errors on them.
Understanding your results
A row from a capture dated 2026-11-19, a London search for sale, looks like this (trimmed to the fields this guide prints):
{ "id": "20762979", "url": "https://www.onthemarket.com/details/20762979/", "transaction": "buy", "title": "1 bedroom flat for sale", "address": "Holmewood Gardens, London SW2", "propertyType": "Flat", "bedrooms": 1, "bathrooms": 1, "price": 290000.0, "currency": "GBP", "priceFrequency": null, "priceQualifier": "Offers in excess of", "priceDisplay": "£290,000", "agentName": "Trevlyn Properties - Maidstone", "agentPhone": "020 3641 3807", "addedOrReduced": "Added < 7 days" } The fields mean what the listing says:
-
priceis the number in GBP. On a rent search it is the rent amount, andpriceFrequencyshowspcm(per calendar month) orpw(per week). -
priceQualifiercarries wording such as "Offers in excess of" when the listing uses it, and isnullotherwise. -
addedOrReducedis the status tag the site shows, for example "Added < 7 days". -
agentNameandagentPhoneare the branch details the listing publishes.
Read priceDisplay for the text a reader sees, and price for sorting. The price value is the same listing price in GBP as a plain number, so it sorts correctly, while priceDisplay keeps the site's formatting with the pound sign and commas.
Two fields are easy to misread. isSpotlight, isRecentlyAdded and isExclusive are the site's own flags, not ours. keyFeatures is a list of the bullets the agent wrote, so the wording varies from listing to listing.
Pro tips and advanced usage
- Narrow the location before you raise the caps. A search stops at 34 pages (about 1,020 listings). For a larger area, run several smaller location slugs and merge the rows by
id. - Use
maxPageswhile you test. A cap of one page returns a single page of listings, which is enough to check the field names before a large run. - Keep
maxItemsat what you need. It caps rows across all pages, so a run stops once it has that many. - Switch the transaction for rentals. Set
transactiontorentand readpriceFrequencybefore you compare prices, because a rent and a sale price are not the same kind of number. - Deduplicate on
id. Each property ID comes back once per run, but two runs for overlapping locations can return the same property. - Keep the caps on test runs. Set
maxItemsandmaxPageswhile you check the output. For a full search, removemaxPagesand raisemaxItems: withoutmaxPagesthe run walks every page the site reports for the search, or stops once it reachesmaxItems, which defaults to 1,000 rows. - Read the dataset from any language. The rows come back through the Apify API, so any language with an Apify client can read them.
Troubleshooting common issues
- An unknown location slug. Copy the slug from the search URL on onthemarket.com, for example
londonfrom/for-sale/property/london/. An unknown slug ends the run with an error, so check the slug first. - A search that matches nothing. The run ends with a status message and no rows. Widen the location or check the
transactionvalue. - Empty fields on some rows. Bedrooms, coordinates and key features are missing on some listings. Read them with
.get()as in Step 4. - Where to check errors. Open the run in the Apify Console. Its log shows the status message and the reason for any failed run.
Next steps
Once the script prints the fields you need, save the rows with json.dump(items, f, ensure_ascii=False, indent=2), or export the dataset from the Console as CSV. Run the script on a schedule with your usual scheduler to build a file of new listings over time, and try rent on the same location to compare the two markets.
For current pricing and details, see the Store page.
What are you planning to track on OnTheMarket? Drop a comment below.
