Skip to main content

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 :

  1. Create an account at https://data.rte-france.com/.

  2. Create an application for web server and start associating the API to this application.

  3. 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:

  • APIService and PrevisionType are enums so you can pass them directly as strings.
  • Timestamps passed to client methods must be timezone-aware (Pandas Timestamp with 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrte-0.1.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrte-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

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

Hashes for pyrte-0.1.2.tar.gz
Algorithm Hash digest
SHA256 7e7e88e94dcc5603b0d2b4f288df8d2e684fe629d9c3e0f4376e2f154d7de684
MD5 1b20168fdad0a72905e2af212dca93e5
BLAKE2b-256 9fd3ca4fb112542344bc64b52d557e8accd5f0200af07825eb3f71a219acf692

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrte-0.1.2.tar.gz:

Publisher: publish.yml on enzo-boulin/pyrte

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pyrte-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46437087f4d2dd1a97cb9306678e884dcb41fa7cac42c23e534aded5b6c485f3
MD5 d9b4fd18dd8b4f86fa9b5363630f9294
BLAKE2b-256 70e20a120c332996e43f2bc75ceb58d5512e00ab0f9bb1cc40ac886f9ce857d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyrte-0.1.2-py3-none-any.whl:

Publisher: publish.yml on enzo-boulin/pyrte

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page