Tools for using the enindex api
Project description
Python API Tools Package
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:
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 ofIndexSegmentobjects."pandas": Returns apandas.DataFrameobject.
Default is"json".
Returns:
- List[IndexSegment] (if
format="json") orpandas.DataFrame(ifformat="pandas").
EachIndexSegmentcontains:dataset(str)timeFrom(str)levelFrom(float)timeTo(str)levelTo(float)
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 apandas.DataFrameobject.
Default is"json".
Returns:
- List[StackElement] (if
format="json") orpandas.DataFrame(ifformat="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 apandas.DataFrameobject.
Default is"json".
Returns:
- List[StackElement] (if
format="json") orpandas.DataFrame(ifformat="pandas").
Stack elements include the same fields asget_stack_at.
Note: Both
timeType = "FROM"andtimeType = "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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file enindex_tools-0.1.1.tar.gz.
File metadata
- Download URL: enindex_tools-0.1.1.tar.gz
- Upload date:
- Size: 20.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74c3aa9718c5bbe10a3fb1c2bd4fa439bb37a5164bbdde59711cbd31a7e5f341
|
|
| MD5 |
c823a2fe2dff5ec0c40703bf2d0287e4
|
|
| BLAKE2b-256 |
06f3aa0c406d8e924b5c44089fd6ee186b978efbb79a1caeb93b3fc74da3754c
|
File details
Details for the file enindex_tools-0.1.1-py3-none-any.whl.
File metadata
- Download URL: enindex_tools-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998a607a7d07f7996d8ffe52f381933d4d69abee39ea0c7e62852233c4235fa4
|
|
| MD5 |
d06b013d177b584dcec9586565ab1993
|
|
| BLAKE2b-256 |
58b4a51758b94db7be0ec797e528f6db49c91bf74705cb738e2a399f07788cf7
|