# 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 and `pydantic` for data validation.
## Installation
Install the library using pip:
```bash
pip install pyfingriaApi
```
## Usage
### Initialization
Create an instance of the `FingridApi` client:
```python
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
```python
latest_data = api_client.get_last_data_by_dataset(datasetId=12345)
print(latest_data)
```
### Fetching Multiple Time Series Data
```python
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
```python
dataset_info = api_client.get_dataset(datasetId=12345)
print(dataset_info)
```
### Fetching Active Notifications
```python
notifications = api_client.get_active_notifications()
print(notifications)
```
### Checking API Health Status
```python
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:
```python
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("fingridapi")
```
## TODO
- Add support for API endpoints such as `GetDatasetFile`, `GetDatasetFileData`, and `GetDatasetShorts`.
- 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](LICENSE) file for details.
## Contributing
Contributions are welcome! Feel free to submit issues or pull requests to enhance the library.
Raw data
{
"_id": null,
"home_page": null,
"name": "pyfingridapi",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "API, Fingrid, FingridApi, FingridOpenData",
"author": null,
"author_email": "Aku Nivala <aku.nivala@otx.fi>",
"download_url": "https://files.pythonhosted.org/packages/7f/7c/90d720374831a8ab9eee0ebafcda0b98c4bd9c7d0d27ebfabf17bc5cb8dc/pyfingridapi-0.1.1.tar.gz",
"platform": null,
"description": "\n# Pyfingridapi\n\n`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.\n\n## Features\n\n- Fetch real-time and historical time-series data.\n- Retrieve detailed dataset metadata.\n- Access active notifications and alerts.\n- Check the health status of the Fingrid API services.\n- Built using `httpx` for robust HTTP interactions and `pydantic` for data validation.\n\n## Installation\n\nInstall the library using pip:\n\n```bash\npip install pyfingriaApi\n```\n\n## Usage\n\n### Initialization\n\nCreate an instance of the `FingridApi` client:\n\n```python\nimport httpx\nfrom pyfingridapi import FingridApi\n\n# Initialize the API client\nwith httpx.Client() as client\n api_client = FingridApi(client=client, x_api_key=\"your_api_key\")\n```\n\n### Fetching the Latest Data by Dataset\n\n```python\nlatest_data = api_client.get_last_data_by_dataset(datasetId=12345)\nprint(latest_data)\n```\n\n### Fetching Multiple Time Series Data\n\n```python\ntime_series_data = api_client.get_multiple_timeseries_data(\n datasetId=[123, 456],\n startTime=\"2024-01-01T00:00:00Z\",\n endTime=\"2024-01-31T23:59:59Z\"\n)\nprint(time_series_data)\n```\n\n### Retrieving Dataset Information\n\n```python\ndataset_info = api_client.get_dataset(datasetId=12345)\nprint(dataset_info)\n```\n\n### Fetching Active Notifications\n\n```python\nnotifications = api_client.get_active_notifications()\nprint(notifications)\n```\n\n### Checking API Health Status\n\n```python\nhealth_status = api_client.get_health_status()\nprint(health_status)\n```\n\n## Models\n\nThe library uses `pydantic` models to structure and validate the data retrieved from the API. Key models include:\n\n- `DataRecord`: Represents a single data point in a time series.\n- `TimeSeriesDataResponse`: Encapsulates time-series data and pagination information.\n- `DataSet`: Contains detailed metadata about a dataset.\n- `ActiveNotifications`: Represents active notifications from Fingrid.\n- `HealthStatus`: Describes the health status of the Fingrid API.\n\n## Logging\n\n`pyfingridapi` uses Python's `logging` module to log errors and debug information. To configure logging:\n\n```python\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger(\"fingridapi\")\n```\n\n## TODO\n\n- Add support for API endpoints such as `GetDatasetFile`, `GetDatasetFileData`, and `GetDatasetShorts`.\n- test this as module\n- push this to pypi_test\n- push this to pypi\n- create documentation site\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Feel free to submit issues or pull requests to enhance the library.\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "This module is intented for easy access to fingrid API",
"version": "0.1.1",
"project_urls": null,
"split_keywords": [
"api",
" fingrid",
" fingridapi",
" fingridopendata"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "43fa9729ec991adb96eb79c161daa9a1ba7e4b474fdc77a79bb1ee7cdb3be03f",
"md5": "f01a30d8a2a7eb18328ab00ad983bbfe",
"sha256": "b86a38a1ab05d4f21e428272d3c9e4ff657a8be37e4261525099c1e1ab01fae2"
},
"downloads": -1,
"filename": "pyfingridapi-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f01a30d8a2a7eb18328ab00ad983bbfe",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6529,
"upload_time": "2024-11-23T16:57:10",
"upload_time_iso_8601": "2024-11-23T16:57:10.275232Z",
"url": "https://files.pythonhosted.org/packages/43/fa/9729ec991adb96eb79c161daa9a1ba7e4b474fdc77a79bb1ee7cdb3be03f/pyfingridapi-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7f7c90d720374831a8ab9eee0ebafcda0b98c4bd9c7d0d27ebfabf17bc5cb8dc",
"md5": "907b1268d8048f2d4de27f2bb33c224b",
"sha256": "e47dad1d7ed9d0822290d1a561d4a347cfadc0f73cdbe5bb146e77b65b991805"
},
"downloads": -1,
"filename": "pyfingridapi-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "907b1268d8048f2d4de27f2bb33c224b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6404,
"upload_time": "2024-11-23T16:57:12",
"upload_time_iso_8601": "2024-11-23T16:57:12.250937Z",
"url": "https://files.pythonhosted.org/packages/7f/7c/90d720374831a8ab9eee0ebafcda0b98c4bd9c7d0d27ebfabf17bc5cb8dc/pyfingridapi-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-23 16:57:12",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pyfingridapi"
}