/gasoline-alert

Python script to monitor and alert for specific gas availability

Primary LanguagePython

Gas Availability Alert

This script monitors gas stations in France and alerts you when the availability of a specific gas type changes. The script uses the API provided by the French government to retrieve the latest data on gas prices and availability.

TL;DR

  1. Install Python 3.x
  2. open a terminal, run pip install requests simpleaudio
  3. Turn up your volume
  4. Launch app.py <gas_type> <postal_code>
  5. Look at the currently best available gas station
  6. Wait to be notified for new updates

Features

  • Monitors gas stations in a specific postal code or all stations in France (Up tp 1000 results, increase the count at your own risks)
  • Alerts when the availability of the specified gas type changes
  • Stores the gas availability history in a CSV file (for later analysis/visualization)
  • Optionally, set a custom time interval between checks

Requirements

To install the required libraries, run:

pip install requests simpleaudio

Usage

To run the script, use the following command:

python app.py <gas_type> <postal_code> <interval>

<gas_type>: The type of gas you want to monitor.

Gas types
GPLc
E85
SP95
SP98
E10
Gazole
<postal_code>: (Optional) The postal code of the area you want to monitor. If not provided, the script will monitor all gas stations in France (first 1000 results). Note that you must input the exact postal code, it won't work with regional ones (44300 will work but 44000 won't)

<interval>: (Optional) The time interval (in seconds) between checks. The default and minimal value is 60 seconds (The API is updated with 1mn interval at most).

Example

To monitor the availability of E10 gas in the 75001 postal code area and check every 5 minutes (300 seconds), run:

python app.py E10 75001 300

Output

The script will output the following information:

  • An alert message when the availability of the specified gas type changes
  • The number of gas stations with changed availability after each check
  • The most recently updated available gas station on the first run

The script will also store the gas availability history in a CSV file within the data folder. The filename will be in the format <postal_code>_<gas_type>_gas_availability_log.csv. If the postal code is not specified, it will be replaced with all.

Notes

This script relies on the API provided by the French government, which may be subject to change. Ensure you have the latest version of the script and that the API is still functioning as expected.

Remember to respect the API usage policy and avoid making excessive requests in a short period of time.