mfapi/README.md
Léo VIALLON GALINIER 53ccb57208 First commit
2025-03-21 08:24:08 +01:00

55 lines
1.5 KiB
Markdown

# Easy access to Meteo-France API
It currently covers downloading of:
- Hourly climatotlogical data for one station
- BRA (Bulletin d'Estimation du risque d'avalanche)
## 0. Get an account on Meteo-France API
Have a look to https://portail-api.meteofrance.fr/web/fr/faq !
## 1.Install
```bash
pip install git+https://git.vln-glr.fr/leo.viallon/mfapi.git
```
## 2.Configuration
Create a file containing;
```ini
[DEFAULT]
application_id = the-application-id-you-got-on-mf-api-website
```
L'application id se trouve sur le site API de Météo-France en cliquant sur user, Mes API, puis Générer Token. Il vous sera affiché une commande curl de la forme suivante:
``curl -k -X POST https://portail-api.meteofrance.fr/token -d "grant_type=client_credentials" -H "Authorization: Basic APPLICATION_ID"``
## 3.Examples
### 3.1 The BRA
```python
import mfapi
c = mfapi.MFAPIClient(config_file='path_to_your_config_file')
c.get_bra(23, format='pdf') # 23 is the massif code of Mercantour (Alps : 1-23, Pyrenees: 64-74, Corsica: 40-41)
```
The file is stored as `BRA_23.pdf`.
You can also get XML format (and images needed to render with):
```python
c.get_bra(23, format='xml', images=True)
```
### 3.2 Climatological data
```python
import mfapi
import datetime
c = mfapi.MFAPIClient(config_file='path_to_your_config_file')
c.get_clim_h('65413400', begin=datetime.datetime(2024, 9, 1), end=datetime.datetime(2024, 12, 1)) # You first have to know the Station id
```
The data is stored under csv format.