Skip to content

WeatherApi is an ASP.NET Core 8 project that provides easy access to weather information using an external API. It offers straightforward endpoints for location search and retrieving weather forecasts, all configurable through environment variables.

License

Macktireh/DotnetWeatherApi

Repository files navigation

Weather Forecasting API

Bienvenue dans WeatherApi, un projet ASP.NET Core 8 permettant d'interagir avec une API météo tierce.

Configuration (sans Docker)

  1. Cloner et variables d'environnement

    git clone https://github.com/Macktireh/DotnetWeatherApi.git
    
    cd DotnetWeatherApi
    

    Copiez le fichier .env.example en tant que .env et renseignez les valeurs appropriées pour les clés API météo.

    WEATHER_API_URL=
    WEATHER_API_KEY=
    
  2. Assurez-vous que les variables d'environnement WEATHER_API_URL et WEATHER_API_KEY sont définies.

sans Docker

  1. Installez les dépendances nécessaires avec la commande :

    dotnet restore
  2. Lancez l'application avec la commande :

    dotnet run

avec Docker

  1. Construisez et lancez l'application avec Docker en utilisant la commande :

    docker compose

    docker-compose up --build

    docker only

    docker run --name weatherapi -p 8080:8080 -p 8081:8081 -e WEATHER_API_URL=YOUR_WEATHER_API_URL -e WEATHER_API_KEY=YOUR_WEATHER_API_KEY macktireh/weatherapi:1.0 

    ou

    docker run --name weatherapi -p 8080:8080 -p 8081:8081 --env-file .env macktireh/weatherapi:1.0 
  2. Accédez à Swagger pour explorer les endpoints de l'API :

    http://localhost:8080/swagger

Endpoints

Recherche de lieux

Endpoint : /api/search

Prévisions météo

Endpoint : /api/forecast

  • Méthode : GET
  • Paramètres :
    • q (obligatoire) : La requête de recherche.
    • days (facultatif) : Le nombre de jours de prévisions (par défaut, 3).
    • lang (facultatif) : La langue de la réponse (par défaut, "en").
  • Exemple : http://localhost:5000/api/forecast?q=Paris

About

WeatherApi is an ASP.NET Core 8 project that provides easy access to weather information using an external API. It offers straightforward endpoints for location search and retrieving weather forecasts, all configurable through environment variables.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published