RatpAPI Python Wrapper
Overview
RatpAPI is a Python wrapper for interacting with the RATP (Régie Autonome des Transports Parisiens) API. This library provides easy access to real-time traffic information, line-specific traffic details, and affluence data for journeys on the RATP network in Paris.
Features
- Fetch global traffic information on the RATP network.
- Retrieve traffic information for specific lines using the
LineIDenum for easy reference. - Get affluence data for journeys on particular lines.
- Utilizes Pydantic models for data validation and parsing.
Installation
To use RatpAPI in your project, you can install it via pip:
pip install ratp-api-python
Usage
a
Setting Up
First, import the RatpAPI class and initialize it with your API key:
from ratp_api.main import RatpAPI
api = RatpAPI()
Using the LineID Enum
The LineID enum provides a convenient way to reference specific lines by their IDs:
from ratp_api.enums import LineID
# Example: Using LineID for RER A
line_id = LineID.RER_A
Fetching Global Traffic Information
To get global traffic data:
global_traffic = api.get_global_traffic()
print(global_traffic)
Fetching Line-Specific Traffic
To get traffic information for a specific line using the LineID enum:
line_data = api.get_line_traffic(line_id=LineID.METRO_14)
for situation in line_data.situations:
print(situation)
# Output:
# isActive=True isPlanned=True criticity='HIGH' messages=["Jusqu'au 04/02, le week-end, trafic interrompu sur l'ensemble de la ligne en raison de travaux. Bus de remplacement. Plus d'informations sur la page dédiée."]
# isActive=False isPlanned=True criticity='HIGH' messages=["Du 01/02 au 08/02, du lundi au jeudi à partir de 22h, trafic interrompu sur l'ensemble de la ligne en raison de travaux. Bus de remplacement. Plus d'informations sur la page dédiée."]
# isActive=False isPlanned=True criticity='HIGH' messages=["Jusqu'au 31/01, du lundi au jeudi à partir de 22h, trafic interrompu sur l'ensemble de la ligne en raison de travaux. Bus de remplacement. Plus d'informations sur la page dédiée."]
Fetching Affluence for Journeys
To get affluence data for a specific journey on a line:
line_id = LineID.RER_A # Using LineID enum
affluence_data = api.get_line_affluence(line_id=line_id)
print(affluence_data)
Fetching Affluence for All Lines
To get affluence data for all lines:
all_lines_affluence = api.get_all_lines_affluence()
print(all_lines_affluence)
Contributing
Contributions to the RatpAPI project are welcomed!
License
This project is licensed under the MIT License.
Metadata
Release files for ratp-api 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ratp_api-1.0.3.tar.gz | 8.2 kB | Without provenance | Details for ratp_api-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ratp_api-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for ratp_api-1.0.3-py3-none-any.whl |
Total release size: 15.6 kB
Release files / ratp_api-1.0.3.tar.gz
| Download URL | ratp_api-1.0.3.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7bd5234ee7762eee8eeb21b51ed6e35dab1cff9ce35c3ae5df0a0373ff5e752e
|
|
BLAKE2b-256 checksum How to use checksums |
9961d1fe33b3ed939f633ef5501dc56d639f646c1c40eda94e6dad35967c1452
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / ratp_api-1.0.3-py3-none-any.whl
| Download URL | ratp_api-1.0.3-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8125d2604315c349bc89acc27e788ffc1797a29a08d5680f158d1fa568ab6b3d
|
|
BLAKE2b-256 checksum How to use checksums |
115772f05ed6372133972920fe582a18e3c29c5bb7e2afeca2d6143616a015cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for ratp-api 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.