meteofrance_publicapi.core module#
Core module for the meteofranceapi package.
- class meteofrance_publicapi.core.MeteoFranceAPI(api_key: str | None = None, token: str | None = None, application_id: str | None = None)[source]#
Bases:
object
- _get_request(url, params=None)[source]#
Make a get request to the API.
- Parameters:
url (str) – the url to request
params (dict) – the parameters to pass to the request
- Returns:
requests.Response – the response of the request
- _token_expired(res)[source]#
Check if the token is expired.
- Returns:
bool – True if the token is expired, False otherwise.
- connect()[source]#
Connect to the meteo-France API.
If the API key is provided, it is used to authenticate the user. If the token is provided, it is used to authenticate the user. If the application ID is provided, a token is requested from the API.
- get_token()[source]#
request a token from the meteo-France API.
The token lasts 1 hour, and is used to authenticate the user. If a new token is requested before the previous one expires, the previous one is invalidated. A local cache is used to avoid requesting a new token at each run of the script.