Python Wrapper For Weather API
Project description
WeatherPy - A python Wrapper for Weather
WeatherPy is a simple Python module for fetching current weather conditions and future weather forecasts using the WeatherAPI. It abstracts the complexity of dealing with the API and provides straightforward functions for retrieving weather data by just providing the city name.
Features
-
Get current weather information, including temperature, weather condition, and wind speed.
-
Fetch a 5-day weather forecast, including daily maximum and minimum temperatures and weather conditions.
Installation
To install WeatherPy, you need to have Python installed on your machine. Install the required dependency by running:
pip install Weatherpy-1
Usage
Import the Module
Import the functions from the weatherpy module to get started.
from WeatherPy.weather_utils import GetWeather, FutureForecast
Get Current Weather
Use the GetWeather function to retrieve the current weather for a specific city.
Example
from WeatherPy.weather_utils import GetWeather
city = "London"
current_weather = GetWeather(city)
if isinstance(current_weather, dict):
print(f"Temperature: {current_weather['temprature_c']}°C")
print(f"Condition: {current_weather['condition']}")
print(f"Wind Speed: {current_weather['wind']} kph")
else:
print(current_weather)
Output
Temperature: 15°C
Condition: Partly cloudy
Wind Speed: 12 kph
Get Future Forecast
Use the FutureForecast function to get a 5-day weather forecast for a given city.
Example
from WeatherPy.weather_utils import FutureForecast
city = "London"
forecast = FutureForecast(city)
if isinstance(forecast, list):
for day in forecast:
print(f"Date: {day['date']}")
print(f"Max Temp: {day['max_temp']}°C")
print(f"Min Temp: {day['min_temp']}°C")
print(f"Condition: {day['condition']}")
print()
else:
print(forecast)
Output
Date: 2024-08-05
Max Temp: 22°C
Min Temp: 15°C
Condition: Sunny
Date: 2024-08-06
Max Temp: 23°C
Min Temp: 16°C
Condition: Cloudy
API Key Management
WeatherPy handles the API key internally. Users only need to provide the city name as a parameter to the functions.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributing
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.
-
Fork the repository.
-
Create your feature branch (
git checkout -b feature/YourFeature). -
Commit your changes (
git commit -am 'Add some feature'). -
Push to the branch (
git push origin feature/YourFeature). -
Create a new Pull Request.
Acknowledgements
- WeatherAPI for providing weather data.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file Weatherpy-1-0.4.tar.gz.
File metadata
- Download URL: Weatherpy-1-0.4.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
217a167b02f581d2bb4af1b6bb1af620589f57e090b6c7bb08affd5291b031e9
|
|
| MD5 |
62fc692d39daf7e48779b6c89a836a9a
|
|
| BLAKE2b-256 |
4ba54206c0851a5a1a1e2d9111979dbda36339e718607a5314a4fbc2e2c2b54b
|
File details
Details for the file Weatherpy_1-0.4-py3-none-any.whl.
File metadata
- Download URL: Weatherpy_1-0.4-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
981ea7f73b4bcd4b406242693664c8bbceb61284001e02d22a936cd0cfad400f
|
|
| MD5 |
bdb8e7c604fbcab192e1fcf48fcdd9db
|
|
| BLAKE2b-256 |
e8683f5e4d6ffa5d236bfbd663dddb4deb68287617208abbe6324cf772f8902a
|