šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

Weatherpy-1

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Weatherpy-1

Python Wrapper For Weather API

0.4
PyPI
Maintainers
1

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

Keywords

python

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts