Skip to content

Commit 6130477

Browse files
committed
Update README
1 parent d05aeab commit 6130477

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

README.md

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
## Introduction
88

9-
Reporting API client for Python
9+
A Python client for interacting with the Frequenz Reporting API to efficiently retrieve metric and state data from microgrids.
10+
11+
> **Who should use this?**
12+
> This client is for developers building applications on top of Frequenz's platform who need structured access to historical component or sensor data via Python or CLI.
13+
1014

1115
## Supported Platforms
1216

@@ -37,6 +41,12 @@ pip install frequenz-client-reporting==$VERSION
3741

3842
### Initialize the client
3943

44+
To use the Reporting API client, you need to initialize it with the server URL and authentication credentials.
45+
The server URL should point to your Frequenz Reporting API instance, and you will need an authentication key and a signing secret.
46+
47+
> **Security Note**
48+
> Always keep your authentication key and signing secret secure. Do not hard-code them in your source code or share them publicly.
49+
4050
```python
4151
from datetime import datetime, timedelta
4252
import os
@@ -58,23 +68,37 @@ you can also set the sampling period for resampling using the `resampling_period
5868
parameter. For example, to resample data every 15 minutes, use
5969
`resampling_period=timedelta(minutes=15)`.
6070

61-
### Query metrics for a single microgrid and component:
71+
72+
### Query metrics for a single microgrid and component
73+
74+
This method supports:
75+
- Selecting specific `microgrid_id` and `component_id`
76+
- Choosing one or more `metrics` to retrieve
77+
- Defining a time range with `start_time` and `end_time`
78+
- Optional downsampling using `resampling_period` (e.g., `timedelta(minutes=15)`)
6279

6380
```python
81+
# Asynchronously collect metric data samples into a list
6482
data = [
6583
sample async for sample in
6684
client.list_single_component_data(
67-
microgrid_id=1,
68-
component_id=100,
69-
metrics=[Metric.AC_ACTIVE_POWER, Metric.AC_REACTIVE_POWER],
70-
start_time=datetime.fromisoformat("2024-05-01T00:00:00"),
71-
end_time=datetime.fromisoformat("2024-05-02T00:00:00"),
72-
resampling_period=timedelta(seconds=1),
85+
microgrid_id=1, # ID of the microgrid to query
86+
component_id=100, # ID of the specific component to query
87+
metrics=[ # List of metrics to retrieve
88+
Metric.AC_ACTIVE_POWER, # AC active power
89+
Metric.AC_REACTIVE_POWER # AC reactive power
90+
],
91+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"), # Start of query range (UTC)
92+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"), # End of query range (UTC)
93+
resampling_period=timedelta(seconds=5), # Optional: downsample data to 5-second intervals
7394
)
7495
]
7596
```
7697

77-
### Query metrics for a single microgrid and sensor:
98+
99+
### Query metrics for a single microgrid and sensor
100+
101+
To query sensor data for a specific microgrid, you can use the following method.
78102

79103
```python
80104
data = [
@@ -93,6 +117,8 @@ data = [
93117

94118
### Query metrics for multiple microgrids and components
95119

120+
It is possible to query data for multiple microgrids and their components in a single request.
121+
96122
```python
97123
# Set the microgrid ID and the component IDs that belong to the microgrid
98124
# Multiple microgrids and components can be queried at once
@@ -121,6 +147,8 @@ data = [
121147

122148
### Query metrics for multiple microgrids and sensors
123149

150+
Equivalent to the previous example, multiple microgrids and their sensors can be queried in a single request.
151+
124152
```python
125153
# Set the microgrid ID and the sensor IDs that belong to the microgrid
126154
# Multiple microgrids and sensors can be queried at once
@@ -148,6 +176,8 @@ data = [
148176

149177
### Optionally convert the data to a pandas DataFrame
150178

179+
For easier data manipulation and analysis, you can convert the collected data into a pandas DataFrame.
180+
151181
```python
152182
import pandas as pd
153183
df = pd.DataFrame(data)
@@ -156,8 +186,9 @@ print(df)
156186

157187
## Command line client tool
158188

159-
The package contains a command-line tool that can be used to request
189+
The package contains a command-line tool that can be used to request
160190
microgrid component data from the reporting API.
191+
161192
```bash
162193
reporting-cli \
163194
--url localhost:4711 \
@@ -172,4 +203,4 @@ reporting-cli \
172203
--states \
173204
--bounds
174205
```
175-
In addition to the default CSV format the data can be output as individual samples or in `dict` format.
206+
In addition to the default CSV format the individual samples can also be output using the `--format iter` option.

0 commit comments

Comments
 (0)