This module is intented for easy access to fingrid API
Project description
Pyfingridapi
pyfingridapi
is a Python client library for interacting with the Fingrid API. It provides convenient methods for accessing time-series data, dataset information, notifications, and the health status of the Fingrid API.
Features
- Fetch real-time and historical time-series data.
- Retrieve detailed dataset metadata.
- Access active notifications and alerts.
- Check the health status of the Fingrid API services.
- Built using
httpx
for robust HTTP interactions andpydantic
for data validation.
Installation
Install the library using pip:
pip install pyfingriaApi
Usage
Initialization
Create an instance of the FingridApi
client:
import httpx
from pyfingridapi import FingridApi
# Initialize the API client
with httpx.Client() as client
api_client = FingridApi(client=client, x_api_key="your_api_key")
Fetching the Latest Data by Dataset
latest_data = api_client.get_last_data_by_dataset(datasetId=12345)
print(latest_data)
Fetching Multiple Time Series Data
time_series_data = api_client.get_multiple_timeseries_data(
datasetId=[123, 456],
startTime="2024-01-01T00:00:00Z",
endTime="2024-01-31T23:59:59Z"
)
print(time_series_data)
Retrieving Dataset Information
dataset_info = api_client.get_dataset(datasetId=12345)
print(dataset_info)
Fetching Active Notifications
notifications = api_client.get_active_notifications()
print(notifications)
Checking API Health Status
health_status = api_client.get_health_status()
print(health_status)
Models
The library uses pydantic
models to structure and validate the data retrieved from the API. Key models include:
DataRecord
: Represents a single data point in a time series.TimeSeriesDataResponse
: Encapsulates time-series data and pagination information.DataSet
: Contains detailed metadata about a dataset.ActiveNotifications
: Represents active notifications from Fingrid.HealthStatus
: Describes the health status of the Fingrid API.
Logging
pyfingridapi
uses Python's logging
module to log errors and debug information. To configure logging:
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("fingridapi")
TODO
- Add support for API endpoints such as
GetDatasetFile
,GetDatasetFileData
, andGetDatasetShorts
. - test this as module
- push this to pypi_test
- push this to pypi
- create documentation site
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Feel free to submit issues or pull requests to enhance the library.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file pyfingridapi-0.1.1.tar.gz
.
File metadata
- Download URL: pyfingridapi-0.1.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e47dad1d7ed9d0822290d1a561d4a347cfadc0f73cdbe5bb146e77b65b991805 |
|
MD5 | 907b1268d8048f2d4de27f2bb33c224b |
|
BLAKE2b-256 | 7f7c90d720374831a8ab9eee0ebafcda0b98c4bd9c7d0d27ebfabf17bc5cb8dc |
File details
Details for the file pyfingridapi-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pyfingridapi-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b86a38a1ab05d4f21e428272d3c9e4ff657a8be37e4261525099c1e1ab01fae2 |
|
MD5 | f01a30d8a2a7eb18328ab00ad983bbfe |
|
BLAKE2b-256 | 43fa9729ec991adb96eb79c161daa9a1ba7e4b474fdc77a79bb1ee7cdb3be03f |