Get Started with the Enact API

Upon subscribing to the Enact API, you should be issued a Username and Public API Key from the Enact team.

Please contact [email protected] if you have not, or submit feedback via the speech-bubble icon in the top-right of the Enact website.

Using the LCPDelta Python package

With the LCPDelta Python package, you can interact with our Enact API as per the following example:

from lcp_delta import enact
from datetime import date

username = "insert_username_here"
public_api_key = "insert_public_api_key_here"

api_helper = enact.APIHelper(username, public_api_key)

# Example dates
from_date = date(2022,4,1)
to_date = date(2023,5,31)

# Example series
series_id = "LcpDemandvsGrid"

response = api_helper.get_series_data(
    series_id,
    from_date,
    to_date,
    country_id = "Gb",
    time_zone_id="UTC"
)

print(response.head(5)) #print the top 5 rows of data
from lcp_delta import enact
from datetime import date
import asyncio

username = "insert_username_here"
public_api_key = "insert_public_api_key_here"

async def main():
	api_helper = enact.APIHelper(username, public_api_key)

  # Example dates
  from_date= date(2022,4,1)
  to_date = date(2023,5,31)

  # Example series
  series_id = "LcpDemandvsGrid"

  response = api_helper.get_series_data_async(
      series_id,
      from_date,
      to_date,
      country_id = "Gb",
      time_zone_id="UTC"
  )

	print(response.head(5)) #print the top 5 rows of data
  
asyncio.run(main())

Please note that you will need to replace the "username" and "public_api_key" sections of the code to reflect your details.

To run the code, save the example above to a file called GetSeriesData.py and then run the following command in the terminal from the same directory as the saved file.

py .\GetSeriesData.py

In this specific example we are retrieving series data for the "LcpDemandvsGrid" series between the dates 1-4-2022 and 31-05-2023.

To see the range of functionality included in this package, and for details on specific API methods and parameters, please refer to our API Reference where we include examples from our Python package with each endpoint.

Responses from the Series Data and History of Forecast methods will be in pandas DataFrame format, and the rest of the methods will return Python dictionaries.


Using Custom Code

If you are using your own custom code to interact with the Enact API directly, you can follow the pattern detailed in the below general examples:

var httpClient = new HttpClient();

httpClient.BaseAddress = new Uri(@"https://enactapifd.lcp.uk.com");
httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer <BEARER_TOKEN>");

var result = await httpClient.PostAsync("/EnactAPI/<ENDPOINT_PATH>", <REQUEST_OBJECT>);
string contents = await result.Content.ReadAsStringAsync();
curl -X POST \
https://enactapifd.lcp.uk.com/EnactAPI/<ENDPOINT_PATH>
-H 'Content-Type: application/json' \
-d '<REQUEST_OBJECT>' \
-H 'Authorization: Bearer <BEARER_TOKEN>'
-H 'cache-control: no-cache'

The values in the examples are as follows:

  • BEARER_TOKEN: Your bearer token retrieved from the Enact auth endpoint (see Managing Bearer Tokens).
  • ENDPOINT_PATH: The relative path to a specific Enact API endpoint (please note that the base URL may be different for certain endpoints).
  • REQUEST_OBJECT: An object with fields that specify and refine your data search.

Responses from direct endpoints will be in JSON format.

For details on specific Enact API endpoints, please refer to our API Reference.