Skip to main content

Tools for using the enindex api

Project description

Python API Tools Package

PyPI version
License: GPL v3

Overview

This Python package provides a suite of tools to simplify interaction with the EnIndex API. This library abstracts the complexities of making requests, handling authentication and parsing results so you can focus on building your application.


Features

  • Easy API Integration: Streamlined methods for interacting with the EnIndex API.
  • Automated Chunking and Rate Limiting: Large requests are automatically chunked and rate limited.
  • Authentication Handling: Built-in support for API keys and token management.
  • Result Parsing: Get results directly as a pandas dataframe or JSON.

Installation

Install the package via pip:

pip install enindex-tools

Usage

1. Create a .env file

Enindex tools uses dotenv to handle your config.

You will need to add a new file to your project folder named ".env" containing the folowing environment variables.

If you are able to log into the EnIndex platform you will have these details. Your API key can be found by clicking on the user menu in the top right of the platform:

Description of Image

E.g. if you log into https://alpha.enindex.com with the username jon.doe@acme.com your .env will look like this:

ENINDEX_SUBDOMAIN = alpha
ENINDEX_USERNAME = jon.doe@acme.com
ENINDEX_API_KEY = 9fafec**********************************************************

2. Make Requests

from enindex_tools import Api
import datetime as dt

# Initialize the Api
api = Api()

# Make a request
stack = api.get_stack_at(dt.datetime.now(),format='pandas')

# Do some analysis
print(f'NESO are spending £{stack["revenueRate"].sum()} per hour right now.')

Contributing

The enindex_tools package is intended to be an open source project and contributions are welcomed. The github repo will be made public soon. For now, contact prj@enindex.com if you have suggestions.


Support

If you have questions or need assistance, feel free to reach out to prj@enindex.com


Acknowledgments

Thank you for using this package! We hope it simplifies your API interaction and accelerates your development process.

API Class Documentation

get_index

Description:

Retrieves an index dataset within a specified time range and returns the data in the requested format.

Parameters:

  • dataset (str):
    Identifier of the index dataset, e.g., "NET_CCL_ND".

  • time_from (datetime.datetime):
    Start time of the query. If not on a minute boundary, it is rounded down to the prior minute boundary. Must include timezone information.

  • time_to (datetime.datetime):
    End time of the query. If not on a minute boundary, it is rounded up to the next minute boundary. Must include timezone information.

  • format (str, optional):
    Format of the returned data.

    • "json": Returns a list of IndexSegment objects.
    • "pandas": Returns a pandas.DataFrame object.
      Default is "json".
  • bm_unit (str, optional):
    Make a request for a specific BMU. This will return a dataset for a specific bmunit. E.g. requesting with dataset="PN" and bm_unit="T_COSO-1" will return Physical Notifications for Coryton South.

Returns:

  • List[IndexSegment] (if format="json") or pandas.DataFrame (if format="pandas").
    Each IndexSegment contains:
    • dataset (str)
    • timeFrom (str)
    • levelFrom (float)
    • timeTo (str)
    • levelTo (float)
    • bmUnit (optional - will only be included if data is bmu specific.) (float)

get_bmu_info

Description:

Retrieves Balancing Mechanism Unit information. Either for a specific BMU or all BMUs in the platform.

Parameters:

  • format (str, optional):
    Format of the returned data.

    • "json": Returns a list of BmuInfo objects.
    • "pandas": Returns a pandas.DataFrame object.
      Default is "json".
  • bm_unit (str, optional):
    Make a request for a specific BMU. This will return information for a specific BMU only.

Returns:

  • List[BmuInfo] (if format="json") or pandas.DataFrame (if format="pandas").
    A BmuInfo object contains (with example values):

    • bmUnit: "T_COSO-1",
    • bmuName: "Coryton Power Station",
    • bmuType: "T",
    • constraintGroups: ["B15"],
    • dataset: "BMU_INFO",
    • fuelType: "CCGT",
    • furtherFuelType: null,
    • gspGroupId: null,
    • gspGroupName: null,
    • interconnectorId: null,
    • latitude: 51.542919,
    • longitude: 0.834961,
    • nationalGridBmUnit: "COSO-1",
    • ngFuelType: "CCGT",
    • partyId: "CECL",
    • partyName: "Coryton Energy Company Ltd"

get_stack_at

Description:

Fetches the system stack at a specific time and returns it in the requested format.

Parameters:

  • time (datetime.datetime):
    Time for which to retrieve the system stack. If not on a minute boundary, it is rounded down to the prior minute boundary. Must include timezone information.

  • format (str, optional):
    Format of the returned data.

    • "json": Returns a list of stack elements.
    • "pandas": Returns a pandas.DataFrame object.
      Default is "json".

Returns:

  • List[StackElement] (if format="json") or pandas.DataFrame (if format="pandas").
    Stack elements include:
    • timeType (str)
    • bmUnit (str)
    • elementId (int)
    • time (str)
    • elementType (str)
    • commitmentTime (int)
    • direction (str)
    • eFlaggedAccepted, eFlaggedNet, eFlaggedReversed (int)
    • mainPrice (float)
    • memberOf (list[str])
    • noticeTime (int)
    • pairId (int)
    • quantity, quantityAccepted, quantityAvailable (float)
    • revenueRate (float)
    • reversePrice (float)
    • sFlaggedAccepted, sFlaggedNet, sFlaggedReversed (int)
    • side (str)
    • zeroToSel (bool)
    • zeroToSil (bool)

Note: Only elements with timeType = "FROM" are returned, corresponding to the instant immediately after the specified time.


get_bmu_stack

Description:

Retrieves stack elements for a specific BMU (Balancing Mechanism Unit) within a given time range.

Parameters:

  • bm_unit (str):
    Identifier of the BMU, e.g., "T_COSO-1".

  • time_from (datetime.datetime):
    Start time of the query. If not on a minute boundary, it is rounded down to the prior minute boundary. Must include timezone information.

  • time_to (datetime.datetime):
    End time of the query. If not on a minute boundary, it is rounded up to the next minute boundary. Must include timezone information.

  • format (str, optional):
    Format of the returned data.

    • "json": Returns a list of stack elements.
    • "pandas": Returns a pandas.DataFrame object.
      Default is "json".

Returns:

  • List[StackElement] (if format="json") or pandas.DataFrame (if format="pandas").
    Stack elements include the same fields as get_stack_at.

Note: Both timeType = "FROM" and timeType = "TO" elements are included, representing the instant before and after the requested time.

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

enindex_tools-0.1.3.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

enindex_tools-0.1.3-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file enindex_tools-0.1.3.tar.gz.

File metadata

  • Download URL: enindex_tools-0.1.3.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for enindex_tools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 31b35e78dec51040584ca9171b9f492f0a90ae1923cea6f3ba653524c16fa97a
MD5 5ad9f68cf19d1aff47d3b1f9c42e2cd8
BLAKE2b-256 141387255c9f63b97ebb4c1df212020959990c6ff5dc165e9f1973c2d0e77014

See more details on using hashes here.

File details

Details for the file enindex_tools-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: enindex_tools-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.9.3-76060903-generic

File hashes

Hashes for enindex_tools-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 900fbc2cf4f03e106bfac02887db98e9756e5b18fadd0b8efe97308c8282cf46
MD5 17333ce6ee1cabd9f19435c9fbad2fa6
BLAKE2b-256 320a2a9ef7011ee10f555018843a4a751fe6d4605d48657f3fb7f52fde9e078b

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