https://github.com/macktireh/dotnetweatherapi
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.
https://github.com/macktireh/dotnetweatherapi
api csharp dotnet dotnet-8 weather
Last synced: 3 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/macktireh/dotnetweatherapi
- Owner: Macktireh
- License: mit
- Created: 2024-02-08T21:56:22.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T20:01:43.000Z (over 2 years ago)
- Last Synced: 2025-02-23T03:46:40.505Z (over 1 year ago)
- Topics: api, csharp, dotnet, dotnet-8, weather
- Language: C#
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```plaintext
git clone https://github.com/Macktireh/DotnetWeatherApi.git
```
```plaintext
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.
```plaintext
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
3. Installez les dépendances nécessaires avec la commande :
```bash
dotnet restore
```
4. Lancez l'application avec la commande :
```bash
dotnet run
```
### avec Docker
5. Construisez et lancez l'application avec Docker en utilisant la commande :
docker compose
```bash
docker-compose up --build
```
docker only
```bash
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
```bash
docker run --name weatherapi -p 8080:8080 -p 8081:8081 --env-file .env macktireh/weatherapi:1.0
```
6. Accédez à Swagger pour explorer les endpoints de l'API :
[http://localhost:8080/swagger](http://localhost:8080/swagger)
## Endpoints
### Recherche de lieux
Endpoint : `/api/search`
- **Méthode** : GET
- **Paramètres** :
- `q` (obligatoire) : La requête de recherche.
- `lang` (facultatif) : La langue de la réponse (par défaut, "en").
- **Exemple** : [http://localhost:5000/api/search?q=Paris](http://localhost:5000/api/search?q=Paris)
### 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](http://localhost:5000/api/forecast?q=Paris)