Domestic Energy Performance Certificates API

Using Swagger & OpenAPI

As of December 2023, we started providing OpenAPI v3 schemas for all our APIs. These schemas document all our published API routes and describe the format of the HTTP request parameters we support for querying our API.

In addition to publishing the OpenAPI v3 schemas, we also now provide a Swagger User Interface which can be used to interactively support developers in making requests against the API.

To use this interface to help build and test API requests you will need to first authorise, by clicking the Authorize button in the user interface and providing your Username (your email, printed in the footer when logged in) and Password (your API key: also printed in the footer when logged in).

Note: These OpenAPI schemas do not describe a new API; they simply describe our existing API following the OpenAPI standards. This provides developers with extra tooling support such as our Swagger interface.

If you have any comments on or feedback regarding these additions, please contact us.

Using this API

You require a registered account to use this API, and all requests to this API must be authenticated to your account using HTTP Basic Auth. To do this we use a Base64-encoded account identifier composed of your email address and api-key.

This token must then be included in the HTTP Authorization header on every API request with the Basic authentication scheme, for example:

Both of these tokens are used to authenticate you, so you should take measures to ensure you do not share them publicly, e.g by avoiding commiting them into public source code repositories, or storing them in the source of a publicly accessible website.

Authorization: Basic <encoded-api-key>

Assuming you have already registered, you should have received an email containing your API key.

This token is generated by Base64-encoding the string : which is the concatenation of your email address with the separator : and your api-key .

You may confirm that this works using a simple cURL request asking for all results as CSV.

$ curl -v -X GET  -H "Accept: text/csv" -H "Authorization: Basic <encoded-api-key>" "https://epc.opendatacommunities.org/api/v1/domestic/search"

Alternatively, you may want to create a Python script to initiate the request.

import urllib.request
from urllib.parse import urlencode


token = "<encoded-api-key>"

headers = {
    'Accept': 'text/csv',
    'Authorization': f'Basic {token}'
}

with urllib.request.urlopen(urllib.request.Request(
    'https://epc.opendatacommunities.org/api/v1/domestic/search', headers=headers)) as response:
    response_body = response.read()
    print(response_body.decode())
    

NOTE: You should take care to move the secret/api-key outside of this script and ensure it is securely stored and injected into the script from elsewhere. Safe credential management is your responsibility, the scripts provided here are only intended as an easy starting point.

Unless otherwise stated each of our API's support the following Accept headers:

Response Format Accept Header
CSV text/csv
Excel (pre 2007) application/vnd.ms-excel
Excel (post 2007) application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
JSON application/json
Zip (certificates.csv & recommendations.csv) application/zip

Domestic Certificate API

This API can be called by making an authenticated HTTP GET request with an appropriate Accept header to the API endpoint:

https://epc.opendatacommunities.org/api/v1/domestic/certificate/:lmk-key

Where :lmk-key is the LMK key of a certificate from a search result or download. For example we can request the certificate with LMK key of 219873319402019053122194154717408 by making a request to the API at the URL:

https://epc.opendatacommunities.org/api/v1/domestic/certificate/219873319402019053122194154717408

Note: This API recently changed, to expect an LMK key as the identifier instead of a certificate hash. Read more.

When a supported Accept header is set on the request it will return the specified certificate in the requested format. An example of how to request this certificate in CSV format using cURL is shown below:

$ curl -v -H "Accept: text/csv" -H "Authorization: Basic <encoded-api-key>" "https://epc.opendatacommunities.org/api/v1/domestic/certificate/219873319402019053122194154717408"

Or in python do:

import urllib.request
from urllib.parse import urlencode


token = "<encoded-api-key>"

headers = {
    'Accept': 'text/csv',
    'Authorization': f'Basic {token}'
}

# Define base URL and query parameters separately
base_url = 'https://epc.opendatacommunities.org/api/v1/domestic/certificate/219873319402019053122194154717408'
query_params = ''

# Encode query parameters
encoded_params = urlencode(query_params)

# Append parameters to the base URL
full_url = f"{base_url}?{encoded_params}"

# Now make request
with urllib.request.urlopen(urllib.request.Request(full_url, headers=headers)) as response:
    response_body = response.read()
    print(response_body.decode())

Descriptions of all the columns and fields found in the returned data can be found in the glossary.

Domestic Recommendations API

Not all certificates contain recommendations for the property, but where they do they are available via this API route:

https://epc.opendatacommunities.org/api/v1/domestic/recommendations/:lmk-key

If the property has no recommendations a HTTP 404 not found status code will be returned. Note that this api route does not recognise the application/zip mime type.

Recommendations are keyed on the certificates lmk-key, which can be obtained from the certificate's lmk-key field.

$ curl -v -H "Accept: text/csv" -H "Authorization: Basic <encoded-api-key>" "https://epc.opendatacommunities.org/api/v1/domestic/recommendations/219873319402019053122194154717408"

Or in python do:

import urllib.request
from urllib.parse import urlencode


token = "<encoded-api-key>"

headers = {
    'Accept': 'text/csv',
    'Authorization': f'Basic {token}'
}

# Define base URL and query parameters separately
base_url = 'https://epc.opendatacommunities.org/api/v1/domestic/recommendations/219873319402019053122194154717408'
query_params = ''

# Encode query parameters
encoded_params = urlencode(query_params)

# Append parameters to the base URL
full_url = f"{base_url}?{encoded_params}"

# Now make request
with urllib.request.urlopen(urllib.request.Request(full_url, headers=headers)) as response:
    response_body = response.read()
    print(response_body.decode())