Skip to main content

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.

  1. Fork the repository.

  2. Create your feature branch (git checkout -b feature/YourFeature).

  3. Commit your changes (git commit -am 'Add some feature').

  4. Push to the branch (git push origin feature/YourFeature).

  5. Create a new Pull Request.

Acknowledgements

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

Weatherpy-1-0.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Weatherpy_1-0.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

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

Hashes for Weatherpy-1-0.4.tar.gz
Algorithm Hash digest
SHA256 217a167b02f581d2bb4af1b6bb1af620589f57e090b6c7bb08affd5291b031e9
MD5 62fc692d39daf7e48779b6c89a836a9a
BLAKE2b-256 4ba54206c0851a5a1a1e2d9111979dbda36339e718607a5314a4fbc2e2c2b54b

See more details on using hashes here.

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

Hashes for Weatherpy_1-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 981ea7f73b4bcd4b406242693664c8bbceb61284001e02d22a936cd0cfad400f
MD5 bdb8e7c604fbcab192e1fcf48fcdd9db
BLAKE2b-256 e8683f5e4d6ffa5d236bfbd663dddb4deb68287617208abbe6324cf772f8902a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page