Python http client for RTE API
Project description
pyrte
pyrte is a lightweight Python client library for interacting with RTE (Réseau de Transport d'Électricité) public APIs (https://data.rte-france.com). It provides a high-level interface for authentication and data retrieval from RTE endpoints, including automatic handling of per-endpoint OAuth2 tokens.
Key features:
- High-level client for RTE APIs
- Per-endpoint OAuth2 token management
- Utilities to fetch time series data (e.g., short-term consumption)
Installation
Install from PyPI:
pip install pyrte
Testing
Simply run at the root:
pytest
You don't need credentials to run tests
Credentials
For each API you want to request :
-
Create an account at https://data.rte-france.com/.
-
Create an application for web server and start associating the API to this application.
-
In the application tab, one will find the client id and the related client secret code needed for requesting data.
Quick Usage Example
The following example demonstrates how to create an RTEClient and fetch short-term consumption data. Replace the credential placeholders with your real client IDs and secrets.
import pandas as pd
from pyrte.rte_client import RTEClient, APIService, PrevisionType
creds = {
APIService.short_term_consumption: {
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
},
APIService.wholesale_market: {
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
},
}
client = RTEClient(creds)
# Use timezone-aware timestamps (example: CET / +01:00)
start = pd.Timestamp("2025-01-01T00:00:00+01:00")
end = pd.Timestamp("2025-01-02T00:00:00+01:00")
series = client.get_short_term_consumption(start, end, PrevisionType.REALISED)
print(series.head())
Notes:
APIServiceandPrevisionTypeare enums so you can pass them directly as strings.- Timestamps passed to client methods must be timezone-aware (Pandas
Timestampwith tz info). - The library will automatically refresh OAuth2 tokens per service when required.
Contributing
Contributions and bug reports are welcome:
I only implemented one endpoint as an exemple and because it was the one i needed, so feel free to open issues or pull requests to add new functionality !
License
See the LICENSE file for license terms.
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
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 pyrte-0.1.2.tar.gz.
File metadata
- Download URL: pyrte-0.1.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e7e88e94dcc5603b0d2b4f288df8d2e684fe629d9c3e0f4376e2f154d7de684
|
|
| MD5 |
1b20168fdad0a72905e2af212dca93e5
|
|
| BLAKE2b-256 |
9fd3ca4fb112542344bc64b52d557e8accd5f0200af07825eb3f71a219acf692
|
Provenance
The following attestation bundles were made for pyrte-0.1.2.tar.gz:
Publisher:
publish.yml on enzo-boulin/pyrte
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrte-0.1.2.tar.gz -
Subject digest:
7e7e88e94dcc5603b0d2b4f288df8d2e684fe629d9c3e0f4376e2f154d7de684 - Sigstore transparency entry: 720411984
- Sigstore integration time:
-
Permalink:
enzo-boulin/pyrte@5278aeba89361b6ee817afba9a5da880436cac51 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/enzo-boulin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5278aeba89361b6ee817afba9a5da880436cac51 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyrte-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pyrte-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46437087f4d2dd1a97cb9306678e884dcb41fa7cac42c23e534aded5b6c485f3
|
|
| MD5 |
d9b4fd18dd8b4f86fa9b5363630f9294
|
|
| BLAKE2b-256 |
70e20a120c332996e43f2bc75ceb58d5512e00ab0f9bb1cc40ac886f9ce857d7
|
Provenance
The following attestation bundles were made for pyrte-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on enzo-boulin/pyrte
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyrte-0.1.2-py3-none-any.whl -
Subject digest:
46437087f4d2dd1a97cb9306678e884dcb41fa7cac42c23e534aded5b6c485f3 - Sigstore transparency entry: 720411986
- Sigstore integration time:
-
Permalink:
enzo-boulin/pyrte@5278aeba89361b6ee817afba9a5da880436cac51 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/enzo-boulin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5278aeba89361b6ee817afba9a5da880436cac51 -
Trigger Event:
release
-
Statement type: