Skip to main content

Interface the UK Govenment EPC api

Project description

epc-api-python

Simple python client to interface with the EPC data API.

API docs for the domestic api can be found here

API docs for the non-domestic api can be found here

You need to sign up with the EPC api which will provide you with an api key. You need to use the api key in conjunction with your sign up email address, or with the authorisation token that you are provided with to access the api

Installation

This package can be installed by running

pip install epc-api-python

Usage

Some usage examples can be found in the /examples folder

To set up the api import the EpcClient class an initialise the client by tunning

import dotenv
from epc_api.client import EpcClient

your_email = "email you signed up with"
api_key = "api you were emailed after sign up"


# I have auth_token in my environment
client = EpcClient(
    user_email=your_email, api_key=your_email_key, version="v1"
)

client.domestic  # interfaces with the domestic url https://epc.opendatacommunities.org/api/<version>/domestic/
client.non_domestic  # interfaces with the non-domestic url https://epc.opendatacommunities.org/api/<version>/non-domestic/

There are three main functions that you should use. They are used identically for both the domestic and non-domestic urls. These are search, certificate and recommendations, which access the /search, /certificate and /recommendations urls respectively. Detailed description of these urls can be found in the api documentation however each of these functions can be used immediately, for example

search_resp = client.domestic.search()
print(search_resp)

# Test the certificate endpoint
# Use the first lmk_key which is provided as a response from /search
lmk_key = search_resp["rows"][0]["lmk-key"]

certificate_resp = client.domestic.certificate(lmk_key=lmk_key)
print(certificate_resp)

# Test the recommendations endpoint with the same lmk_key
recommendation_resp = client.domestic.recommendations(lmk_key=lmk_key)
print(recommendation_resp)

The client can be set up with multiple mime types, with the default value being application/json. If this value is supplied, the json data is parsed and returned in a list/dictionary format, however for other mime types, the user is presented the content back and it's up to the user to parse the response in a suitable fashion. Some examples of handling different mime types of have provided in /examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

epc-api-python-1.0.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

epc_api_python-1.0.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file epc-api-python-1.0.2.tar.gz.

File metadata

  • Download URL: epc-api-python-1.0.2.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.8

File hashes

Hashes for epc-api-python-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b73f1f5ac88ecf9f91b86032161738024269c8bf20335f1f396614d8ab48ce19
MD5 d6988f2067bd4c8aabca2e229119e289
BLAKE2b-256 91c9192c02e9c301374046e9ddfbac2302f7200a246b5a55c5ff2572027ec4a9

See more details on using hashes here.

File details

Details for the file epc_api_python-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for epc_api_python-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c2a04dad7b8adbafb87ed70ad670e3e384c6b69a026d38409460033e2b075712
MD5 928fa977b1ea66a316b90f66331d6f6a
BLAKE2b-256 d734dce477398c2e7cf08d8892ae965e6614109b400cef28560d720bf7a53523

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page