Skip to content

Commit ff55fb2

Browse files
committed
Update README
Signed-off-by: cwasicki <[email protected]>
1 parent d05aeab commit ff55fb2

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

README.md

Lines changed: 40 additions & 15 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
@@ -53,28 +63,36 @@ SIGN_SECRET= os.environ['REPORTING_API_SIGN_SECRET'].strip()
5363
client = ReportingApiClient(server_url=SERVER_URL, auth_key=AUTH_KEY, sign_secret=SIGN_SECRET)
5464
```
5565

56-
Besides the `microgrid_id`, `component_id`s, `metrics`, start, and end time,
57-
you can also set the sampling period for resampling using the `resampling_period`
58-
parameter. For example, to resample data every 15 minutes, use
59-
`resampling_period=timedelta(minutes=15)`.
66+
### Query metrics for a single microgrid and component
6067

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

6374
```python
75+
# Asynchronously collect metric data samples into a list
6476
data = [
6577
sample async for sample in
6678
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),
79+
microgrid_id=1, # ID of the microgrid to query
80+
component_id=100, # ID of the specific component to query
81+
metrics=[ # List of metrics to retrieve
82+
Metric.AC_ACTIVE_POWER, # AC active power
83+
Metric.AC_REACTIVE_POWER # AC reactive power
84+
],
85+
start_time=datetime.fromisoformat("2024-05-01T00:00:00"), # Start of query range (UTC)
86+
end_time=datetime.fromisoformat("2024-05-02T00:00:00"), # End of query range (UTC)
87+
resampling_period=timedelta(seconds=5), # Optional: downsample data to 5-second intervals
7388
)
7489
]
7590
```
7691

77-
### Query metrics for a single microgrid and sensor:
92+
93+
### Query metrics for a single microgrid and sensor
94+
95+
To query sensor data for a specific microgrid, you can use the following method.
7896

7997
```python
8098
data = [
@@ -93,6 +111,8 @@ data = [
93111

94112
### Query metrics for multiple microgrids and components
95113

114+
It is possible to query data for multiple microgrids and their components in a single request.
115+
96116
```python
97117
# Set the microgrid ID and the component IDs that belong to the microgrid
98118
# Multiple microgrids and components can be queried at once
@@ -121,6 +141,8 @@ data = [
121141

122142
### Query metrics for multiple microgrids and sensors
123143

144+
Equivalent to the previous example, multiple microgrids and their sensors can be queried in a single request.
145+
124146
```python
125147
# Set the microgrid ID and the sensor IDs that belong to the microgrid
126148
# Multiple microgrids and sensors can be queried at once
@@ -148,6 +170,8 @@ data = [
148170

149171
### Optionally convert the data to a pandas DataFrame
150172

173+
For easier data manipulation and analysis, you can convert the collected data into a pandas DataFrame.
174+
151175
```python
152176
import pandas as pd
153177
df = pd.DataFrame(data)
@@ -156,8 +180,9 @@ print(df)
156180

157181
## Command line client tool
158182

159-
The package contains a command-line tool that can be used to request
183+
The package contains a command-line tool that can be used to request
160184
microgrid component data from the reporting API.
185+
161186
```bash
162187
reporting-cli \
163188
--url localhost:4711 \
@@ -172,4 +197,4 @@ reporting-cli \
172197
--states \
173198
--bounds
174199
```
175-
In addition to the default CSV format the data can be output as individual samples or in `dict` format.
200+
In addition to the default CSV format the individual samples can also be output using the `--format iter` option.

0 commit comments

Comments
 (0)