Introduction
The ESPC API allows authorised users to query a variety of statistics about individual properties as well as run current and historical searches across our database of properties.
Version History
| Version | Date | Notes |
|---|---|---|
| 1.0 | 2024-12-01 | First public release |
| 1.1 | 206-01-06 | Updated public API to include Under Offer date in FULL responses |
Authentication
curl "https://publicapi.espc.com/...."
-H "x-api-key: ESPC:KEY"
$ch = curl_init('https://publicapi.espc.com/....');
curl_setopt($ch,CURLOPT_HTTPHEADER,'x-api-key: ESPC:KEY');
...
curl_exec($ch);
To authorize, use a valid API Key in either the request header or the query string parameters:
The Request Header is x-api-key.
The query string parameter that you can use is ApiKey. Watch that the ":"
in the key gets the proper treatment (%3A) if you're sending it in the query string.
$ch = curl_init('https://publicapi.espc.com/....?ApiKey=ESPC:KEY');
...
curl_exec($ch);
curl "https://publicapi.espc.com/....&ApiKey=ESPC:KEY"
We don't recommend that you use both the header and the query string options in the same request, particularly with different keys. But if you do then the request header takes priority.
Make sure to replace ESPC:KEY in these examples with your own API key.
Property Lookup
Property detail: GET /Archive/Property/{property_id}
Obtain basic information about a property listing by querying the API with the property's unique archive ID.
$ch = curl_init('https://publicapi.espc.com/Archive/Registration/NM:+9999999&ApiKey=ESPC:KEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl "https://publicapi.espc.com/Archive/Property/NM:%209999999&ApiKey=ESPC:KEY"
Property detail: GET /Archive/Registration/{espc_registration_id}
Obtain basic information about a property listing by querying the API with the property's ESPC registration id.
$ch = curl_init('https://publicapi.espc.com/Archive/Registration/999999?ApiKey=ESPC:KEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl "https://publicapi.espc.com/Archive/Registration/9999999&ApiKey=ESPC:KEY"
Individual property details
A successful call will return key information about a historical or current registration, including the property's address, type, asking price, and links to the home report, schedule, floor plan, and ESPC listing.
It is not guaranteed that all media will be publicly accessible. In particular, if a relative URL is returned, then access to the media will be through further, authenticated, API calls only.
Successful lookup, compact listing
{
"result": {
"id": "NM: 9999999",
"addressLine1": "16 Mount Doom",
"addressLine2": null,
"addressLine3": null,
"postTown": null,
"postCode": "EH4 1MD",
"latitude": 55.921087493896484,
"longitude": -3.2584912967681885,
"displayAddress": "16 Mount Doom, Edinburgh EH4 1MD",
"typeName": "Second Floor Flat",
"typeId": 14,
"offerType": "OffersOver",
"askingPrice": 199000,
"homeReportUrl": "https://media.scottishhomereports.com/MediaServer/HomeReports/9999999/HomeReport/hr.pdf",
"scheduleUrl": "/Archive/Media/9999999/Schedule",
"floorPlanUrl": "/Archive/Media/9999999/FloorPlan",
"espcUrl": "https://espc.com/properties/details.aspx?pid=9999999"
},
"message": "",
"responseCode": "OK",
"successful": true
}
Registration ID not found, or not accessible
{
"result": null,
"message": "Record with property id [9999999] not found!",
"responseCode": "NOTFOUND",
"successful": false
}
Property Media: GET /Archive/Media/{property_id}/{media_type}
Retrieves the archived media for a property listing, such as images, floor plans, and home reports. Relative URLs returned in the property lookup can be used with this endpoint to retrieve the respective media file.
$ch = curl_init('https://publicapi.espc.com/Archive/Media/999999/FloorPlan?ApiKey=ESPC:KEY');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
Property Search
Archive search: GET /Archive/Search
Search the ESPC archive for current and historical property listings. Specify the search terms as query string parameters.
$q = http_build_query([
'Query' => 'eh4 1ew',
'Type' => 'POSTCODE',
'MaxRadius' => 10000,
'OutputFormat' => 'CSV',
'StartDate' => '2024-01-01',
'EndDate' => '2024-10-01',
'PriceLowLimit' => 170000,
'PriceHighLimit' => 240000,
'PropertyTypeIds' => [42, 44],
'Source' => 'ESPC',
'ApiKey' => 'ESPC:KEY'
]);
$ch = curl_init('https://publicapi.espc.com/Archive/Search?'.$q);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl -X 'GET' \
'https://publicapi.espc.com/Archive/Search?MaxRadius=10000&OutputFormat=CSV&Query=eh4%201ew&Type=POSTCODE&StartDate=2024-01-01&EndDate=2024-10-01&PriceLowLimit=170000&PriceHighLimit=240000&PropertyTypeIds=42&PropertyTypeIds=44&Source=ESPC' \
-H 'accept: text/plain'
Query Parameters
Core parameters
| Parameter | Description | Notes |
|---|---|---|
| StartDate | Earliest date for your query in the form YYYY-MM-DD, e.g. 2024-01-31 | Required |
| EndDate | Latest date for your query in the form YYYY-MM-DD, e.g. 2024-02-28 | Required |
| Type | Type of search to perform, see below for options | Required |
| Query | The search data to query against | Required |
| Source | The source of data: ESPC for the sales archive, or ROS for Registers of Scotland | Required |
Other parameters
| Parameter | Description | Notes |
|---|---|---|
| MaxRadius | The maximum distance from the search point to return results for, in metres. Used for the postcode radius convenience search. | Optional |
| OutputFormat | The format to return the results in, CSV, COMPACT or FULL | Optional |
| PriceLowLimit | Lowest priced properties to return in a search, in £s | Optional |
| PriceHighLimit | Highest priced properties to return in a search, in £s | Optional |
| BedroomsLowLimit | Minimum number of bedrooms in a property | Optional |
| BedroomsHighLimit | Maximum number of bedrooms in a property | Optional |
| Reception | Number of receiption rooms specified in the proerpty archive | Optional |
| Bathroom | Number of bathrooms specified in the property archive | Optional |
| PropertyTypeIds | A repeatable parameter, containing property types to include in the search | Optional |
| PropertyStatuses | A repeatable parameter, containing property statuses to include in the search | Optional |
| From | For paginated or long queries, this is the search index of the first record to return | Optional |
| Limit | For paginated or long queries, this is the number of records to return | Optional |
| SortOrder | The order in which to search and return the results | Optional |
| Filename | If specified, will generate the output with an Attachemnt disposition in the header, and this filename |
Optional |
Search Type
| Search Type | Query Example | Description |
|---|---|---|
| POSTCODE | EH24 1AB | Search by area around a full postcode - e.g. EH24 1AB. The postcode is complete and case sensitive. The MaxRadius parameter should also be be provided with a radius around the geographical centre of the given postcode. Use the ADDRESS search type if you want to search for addresses within a specific postcode only. |
| DISTRICT | Stockbridge | Search by a District name - e.g. Stockbridge. The district name is complete and case sensitive. |
| DISTRICT | 68908 | Search by a district id - e.g. 68908. This is the ESPC district id, and the list of districts is too long to enumerate here. If you are working with other ESPC APIs or BDP-hosted properties, you may have access to a list of relevant districts. |
| ADDRESS | 16 Mount Doom | Search by address - e.g. 16 Mount Doom. The address is loosely matched and is not case sensitive, nor must it be complete. If you would like to search for addresses only within a specific postcode rather than a fuzzier radius search, use this search type. |
| RADIUS | { "latitude": 55, "longitude" -3, "distance": 100 } | Searches around a defined point. The latitude and longitude are the coordinates of the search point, and are provided to the search engine as a small snippet of JSON. The distance field in the JSON is the radius in metres to search around the point. |
| RADIUS | { "postcode": "eh24 1ab", "distance": 100 } | Searches around the midpoint of a given postcode. The postcode is the centre of the search, and the distance is the radius in metres to search around the point. This is functionally equivalent to the full postcode and max radius search, but less convenient to construct. |
Sort Order
SortOrder parameter determines the order for searching. This ordering is applied at the point or running the search. The default search process will not return every property for lengthy or very broad searches, so the sort order has an effect on which properties are returned for some searches.
| SortOrder Parameter | Description |
|---|---|
| DATE_ASC | Sort by the date the property was listed, oldest first |
| DATE_DESC | Sort by the date the property was listed, newest first |
| PRICE_ASC | Sort by the price of the property, lowest first |
| PRICE_DESC | Sort by the price of the property, highest first |
| DISTANCE_ASC | Sort by the distance from the search point, closest first (default if not specified) |
Output format
By default, the search will return a list of matching unique property IDs that you can use for further queries.
| OutputFormat type | Notes |
|---|---|
| FULL | Returns the full details of the properties that match the search criteria. |
| COMPACT | Returns a usable subset of fields that covers most common use cases. This is the recommended format for most queries. |
| CSV | Returns a CSV format for download and processing locally. |
| No value simply returns a list of relevant property archive IDs; useful if you are expecting a large dataset |
Property Type
PropertyTypeIds is a repeatable parameter, and can be used to specify the types of property to include in the search. The values are the property type ids from the ESPC database.
| ID | Property Type | ID | Property Type |
|---|---|---|---|
| 4 | Ground floor flat | 48 | Cluster house |
| 5 | Studio flat | 49 | Town house |
| 6 | Ground floor maisonette | 50 | Cottage |
| 7 | Maisonette | 51 | Chalet |
| 8 | Apartment | 52 | Chalet/Lodge |
| 9 | Penthouse | 53 | Villa |
| 10 | Serviced apartment | 54 | Detached Villa |
| 11 | Duplex | 55 | Semi-detached Villa |
| 12 | Triplex | 56 | Barn Conversion |
| 13 | First Floor Flat | 57 | Farm House |
| 14 | Second Floor Flat | 58 | Finca |
| 15 | Maindoor Flat | 59 | Equestrian facility |
| 16 | Basement Flat | 60 | Longere |
| 17 | Single house plot | 61 | House with land over one acre |
| 18 | Upper Flat | 62 | House Conversion |
| 19 | Lower Flat | 63 | Gite |
| 20 | Third Floor Flat | 64 | Barn |
| 21 | Top Floor Flat | 65 | Trulli |
| 22 | Flat (others) | 66 | Character |
| 23 | Fifth Floor Flat | 67 | Ruins |
| 24 | Garden Flat | 68 | Mill |
| 25 | Garden & Ground Flat | 69 | Castle |
| 26 | Mews Flat | 70 | Village House |
| 27 | Ground & Basement Flat | 71 | Cave House |
| 28 | Double Upper Flat | 72 | Cortijo |
| 29 | Lower Ground Floor Flat | 73 | Country House |
| 30 | Sixth Floor Flat | 74 | Stone House |
| 31 | First Floor & Ground Flat | 75 | Manor House |
| 32 | Triplex Apartment | 76 | Stately Home |
| 33 | Flat Conversion | 77 | Riad |
| 34 | Seventh Floor Flat | 78 | House Boat |
| 35 | Fourth Floor Flat | 79 | Retirement Property |
| 36 | Bungalow | 80 | Sheltered Housing |
| 37 | Terraced bungalow | 81 | Rooms |
| 38 | Semi-detached bungalow | 82 | House share |
| 39 | Detached bungalow | 83 | Flat share |
| 40 | Linked Bungalow | 84 | Hotel Room |
| 41 | House | 85 | Single room |
| 42 | Terraced House | 86 | Double room |
| 43 | End of terrace house | 87 | Off-Plan |
| 44 | Semi-detached house | 88 | Utility |
| 45 | Detached house | 89 | Parking |
| 46 | Link Detached House | 90 | Garages |
| 47 | Mews house | 91 | Lock-ups & car parking |
| 92 |
Property Status
PropertyStatuses is a repeatable parameter, and can be used to specify the statuses of property to include in the search. It can be one or more of:
| PropertyStatuses Parameter | Notes |
|---|---|
| CompleteWithdrawn | |
| SaleComplete | |
| Sold | |
| UnderOffer | |
| Active |
Response
The default response is a list of unique property IDs that match the search criteria. This is useful for further queries using the individual property lookup API.
Successful search
[
"NM: 538999943",
"NM: 539099962",
"NM: 539999083"
]
A CSV output file contains the key dates and prices for each transaction.
CSV output
DisplayAddress,District,OfferType,Valuation,AskingPrice,SellingPrice,Date,PropertyType,Bedrooms,PublicRooms
"27/3 Yellowbrick Road, Edinburgh, EH4 1OZ",Edinburgh,OffersOver,360000,340000,350000,01/05/2022 00:00:00,Second Floor Flat,3,1
JSON (COMPACT) output
The COMPACT output format contains more detailed information in a JSON format, suitable for most search and display applications.
{
"result": [
{
"id": "NM: 9999999",
"addressLine1": "16 Mount Doom",
"addressLine2": null,
"addressLine3": null,
"postTown": null,
"postCode": "EH4 1MD",
"latitude": 55.921087493896484,
"longitude": -3.2584912967681885,
"displayAddress": "16 Mount Doom, Edinburgh EH4 1MD",
"typeName": "Second Floor Flat",
"typeId": 14,
"offerType": "OffersOver",
"askingPrice": 199000,
"homeReportUrl": "https://media.scottishhomereports.com/MediaServer/HomeReports/9999999/HomeReport/hr.pdf",
"scheduleUrl": "/Archive/Media/9999999/Schedule",
"floorPlanUrl": "/Archive/Media/9999999/FloorPlan",
"espcUrl": "https://espc.com/properties/details.aspx?pid=9999999"
}
],
"message": "",
"responseCode": "OK",
"successful": true
}
JSON (FULL) output
{
"result": [
{
"ValuationPrice": 420000,
"AskingPrice": 410000,
"SoldPrice": 435000,
"FirstActiveDate": "2024-10-20",
"ClosingDate": "2024-12-05",
"UnderOfferDate": "2024-12-16",
"SoldDate": "2024-12-25",
"Bedroom": 2,
"PublicRoom": 0,
"MetresSquared": "0.0",
"CouncilTaxBand": "E",
"SellingSolicitorName": "Magus, Magus and Magus LLP",
"PropertyImageUrl": "https://media.scottishhomereports.com/MediaServer/PropertyMarketing/999999/MainImage/999999_0.jpg",
"Id": "NM: 9999999",
"AddressLine1": "7 Bethlehem Court",
"AddressLine2": null,
"AddressLine3": null,
"PostTown": null,
"PostCode": "EH14 1RR",
"Latitude": 55.95871,
"Longitude": -3.2174,
"DisplayAddress": "7 Bethlehem Court,\r\nRestalrig,\r\nEdinburgh,\r\nEH14 1RR",
"TypeName": "Maindoor Flat",
"TypeId": 15,
"OfferType": "OffersOver",
"HomeReportUrl": "https://media.scottishhomereports.com/MediaServer/HomeReports/999999/HomeReport/hr.pdf",
"ScheduleUrl": "https://media.scottishhomereports.com/MediaServer/PropertyMarketing/999999/Schedule/560091.pdf",
"FloorPlanUrl": "https://media.scottishhomereports.com/MediaServer/PropertyMarketing/999999/FloorPlan/fp560091.pdf",
"EspcUrl": "https://espc.com/properties/details.aspx?pid=999999"
}
],
"message": "",
"responseCode": "OK",
"successful": true
}