Runs a SPARQL query against one of the supported endpoints and returns the result as a data frame. Useful for queries that aren't covered by the dedicated helpers, including custom HPI aggregations and Price Paid Data lookups by postcode.
Details
The Land Registry endpoint is free, requires no authentication, and
covers HPI and Price Paid Data. MHCLG's Open Data Communities
endpoint was retired in 2026, so endpoint = "opendatacommunities"
now stops with an error.
See also
Other helpers:
ukh_regions()
Examples
# \donttest{
op <- options(ukhousing.cache_dir = tempdir())
try({
# All HPI observations for Westminster in January 2020
q <- '
PREFIX ukhpi: <http://landregistry.data.gov.uk/def/ukhpi/>
SELECT ?hpi ?avgPrice WHERE {
<http://landregistry.data.gov.uk/data/ukhpi/region/city-of-westminster/month/2020-01>
ukhpi:housePriceIndex ?hpi ;
ukhpi:averagePrice ?avgPrice .
}'
ukh_sparql(q)
})
#> Waiting 2s for retry backoff ■■■■■■■■■■■■■■■
#> Waiting 2s for retry backoff ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
#> hpi avgPrice
#> 1 87.50 1072220
options(op)
# }