openweather-wrapper


Nameopenweather-wrapper JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/SHRISH01/openweather-wrapper
SummaryA Python wrapper for the OpenWeatherMap API to fetch weather data.
upload_time2024-12-17 18:23:39
maintainerNone
docs_urlNone
authorShrish Kamboj
requires_python>=3.12.0
licenseMIT License Copyright (c) 2024 Shrish Kamboj Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords weather openweathermap api wrapper python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenWeather Wrapper

`OpenWeather Wrapper` is a Python package that provides an easy-to-use interface for interacting with various weather APIs like OpenWeatherMap and WeatherStack. It allows users to retrieve current weather data, hourly forecasts, and 7-day weather forecasts for a specified city or geographical coordinates (latitude and longitude). The package also supports data caching, error handling, and data visualization.

## Features

- **Weather Data Fetching**: Fetch current weather data by city name or geographical coordinates (latitude/longitude).
- **Hourly Forecast**: Retrieve hourly weather forecast data for the next 24 hours.
- **7-Day Forecast**: Get the 7-day weather forecast.
- **Error Handling**: Custom error handling for API-related issues.
- **Data Caching**: Cache weather data to reduce API calls using `requests_cache`.
- **Data Visualization**: Plot temperature data for the next 24 hours using `matplotlib`.

## Installation

You can install the package using `pip` (once the package is registered on PyPi) or by cloning the repository:

### Option 1: Install from PyPi (once available)

<pre><code>pip install openweather-wrapper</pre></code>



### Option 2: Install from GitHub (for local development)
<pre><code>git clone https://github.com/yourusername/openweather-wrapper.git
cd openweather-wrapper
pip install .</pre></code>

## Requirements

* Python 3.6 or higher
* requests
* requests_cache
* matplotlib

You can install the required dependencies using pip:

<pre><code>pip install -r requirements.txt</pre></code>

## Usage

#### Initialize the OpenWeather class

To use the package, you'll need to initialize the OpenWeather class with your API key. You can get your API key by signing up at OpenWeatherMap or WeatherStack.

<pre><code>from openweather.weather import OpenWeather
# Initialize the OpenWeather class with your API key
api_key = "your_api_key_here"
weather_api = OpenWeather(api_key)
</pre></code>

#### Get Current Weather Data
You can fetch current weather data by either providing a city name or geographical coordinates (latitude and longitude).

##### By City Name:

<pre><code>weather = weather_api.get_weather(city="London")
print(weather)</pre></code>

##### By Latitude and Longitude:

<pre><code>weather = weather_api.get_weather(lat=51.5074, lon=-0.1278)  # Coordinates for London
print(weather)</pre></code>

#### Get Hourly Forecast (Next 24 Hours)

<pre><code>hourly_forecast = weather_api.get_hourly_forecast(city="Delhi")
print(hourly_forecast)</pre></code>

#### Get 7-Day Forecast

<pre><code>seven_day_forecast = weather_api.get_seven_day_forecast(city="London")
print(seven_day_forecast)</pre></code>

#### Plot Weather Data (Temperature)

<pre><code>weather_api.plot_weather(city="Delhi")</code></pre>

---

### Caching

The package uses requests_cache to cache API responses for a specified duration. This reduces the number of requests made to the API and improves performance for subsequent calls. The default cache duration is 1 hour (3600 seconds), but you can modify it when initializing the class.

<pre><code>weather_api = OpenWeather(api_key="your_api_key_here", cache_duration=3600)  # 1 hour cache duration</pre></code>

### License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.

## Contributing

We welcome contributions! If you would like to contribute to this project, please fork the repository and submit a pull request. Make sure to follow the coding guidelines and write tests for any new functionality.

## Contact

For any questions or support, feel free to open an issue on the GitHub repository or contact us directly at <span style="color:green">shrishkamboz@gmail.com</span>.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SHRISH01/openweather-wrapper",
    "name": "openweather-wrapper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12.0",
    "maintainer_email": null,
    "keywords": "weather, openweathermap, api, wrapper, python",
    "author": "Shrish Kamboj",
    "author_email": "Shrish Kamboj <shrishkamboj@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/27/d2/bdcb597e1d155baebf54172a8dbb28e23755fea00c7b52408e700c33026c/openweather_wrapper-0.1.1.tar.gz",
    "platform": null,
    "description": "# OpenWeather Wrapper\n\n`OpenWeather Wrapper` is a Python package that provides an easy-to-use interface for interacting with various weather APIs like OpenWeatherMap and WeatherStack. It allows users to retrieve current weather data, hourly forecasts, and 7-day weather forecasts for a specified city or geographical coordinates (latitude and longitude). The package also supports data caching, error handling, and data visualization.\n\n## Features\n\n- **Weather Data Fetching**: Fetch current weather data by city name or geographical coordinates (latitude/longitude).\n- **Hourly Forecast**: Retrieve hourly weather forecast data for the next 24 hours.\n- **7-Day Forecast**: Get the 7-day weather forecast.\n- **Error Handling**: Custom error handling for API-related issues.\n- **Data Caching**: Cache weather data to reduce API calls using `requests_cache`.\n- **Data Visualization**: Plot temperature data for the next 24 hours using `matplotlib`.\n\n## Installation\n\nYou can install the package using `pip` (once the package is registered on PyPi) or by cloning the repository:\n\n### Option 1: Install from PyPi (once available)\n\n<pre><code>pip install openweather-wrapper</pre></code>\n\n\n\n### Option 2: Install from GitHub (for local development)\n<pre><code>git clone https://github.com/yourusername/openweather-wrapper.git\ncd openweather-wrapper\npip install .</pre></code>\n\n## Requirements\n\n* Python 3.6 or higher\n* requests\n* requests_cache\n* matplotlib\n\nYou can install the required dependencies using pip:\n\n<pre><code>pip install -r requirements.txt</pre></code>\n\n## Usage\n\n#### Initialize the OpenWeather class\n\nTo use the package, you'll need to initialize the OpenWeather class with your API key. You can get your API key by signing up at OpenWeatherMap or WeatherStack.\n\n<pre><code>from openweather.weather import OpenWeather\n# Initialize the OpenWeather class with your API key\napi_key = \"your_api_key_here\"\nweather_api = OpenWeather(api_key)\n</pre></code>\n\n#### Get Current Weather Data\nYou can fetch current weather data by either providing a city name or geographical coordinates (latitude and longitude).\n\n##### By City Name:\n\n<pre><code>weather = weather_api.get_weather(city=\"London\")\nprint(weather)</pre></code>\n\n##### By Latitude and Longitude:\n\n<pre><code>weather = weather_api.get_weather(lat=51.5074, lon=-0.1278)  # Coordinates for London\nprint(weather)</pre></code>\n\n#### Get Hourly Forecast (Next 24 Hours)\n\n<pre><code>hourly_forecast = weather_api.get_hourly_forecast(city=\"Delhi\")\nprint(hourly_forecast)</pre></code>\n\n#### Get 7-Day Forecast\n\n<pre><code>seven_day_forecast = weather_api.get_seven_day_forecast(city=\"London\")\nprint(seven_day_forecast)</pre></code>\n\n#### Plot Weather Data (Temperature)\n\n<pre><code>weather_api.plot_weather(city=\"Delhi\")</code></pre>\n\n---\n\n### Caching\n\nThe package uses requests_cache to cache API responses for a specified duration. This reduces the number of requests made to the API and improves performance for subsequent calls. The default cache duration is 1 hour (3600 seconds), but you can modify it when initializing the class.\n\n<pre><code>weather_api = OpenWeather(api_key=\"your_api_key_here\", cache_duration=3600)  # 1 hour cache duration</pre></code>\n\n### License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n\n## Contributing\n\nWe welcome contributions! If you would like to contribute to this project, please fork the repository and submit a pull request. Make sure to follow the coding guidelines and write tests for any new functionality.\n\n## Contact\n\nFor any questions or support, feel free to open an issue on the GitHub repository or contact us directly at <span style=\"color:green\">shrishkamboz@gmail.com</span>.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Shrish Kamboj  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python wrapper for the OpenWeatherMap API to fetch weather data.",
    "version": "0.1.1",
    "project_urls": {
        "Bug-Tracker": "https://github.com/SHRISH01/openweather-wrapper/issues",
        "Homepage": "https://github.com/SHRISH01/openweather-wrapper"
    },
    "split_keywords": [
        "weather",
        " openweathermap",
        " api",
        " wrapper",
        " python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50412eb23ae2d58f66dbd07d79588a5ba56060a0d533eaa9722ad84ed1c9a5b1",
                "md5": "d8bf529f60e59346616004f65c7c0fbc",
                "sha256": "e5240911a6d2340f396605091bf0b6a26f5a15da9cc6f82087eb859c5478b5d2"
            },
            "downloads": -1,
            "filename": "openweather_wrapper-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d8bf529f60e59346616004f65c7c0fbc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12.0",
            "size": 10843,
            "upload_time": "2024-12-17T18:23:31",
            "upload_time_iso_8601": "2024-12-17T18:23:31.637263Z",
            "url": "https://files.pythonhosted.org/packages/50/41/2eb23ae2d58f66dbd07d79588a5ba56060a0d533eaa9722ad84ed1c9a5b1/openweather_wrapper-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27d2bdcb597e1d155baebf54172a8dbb28e23755fea00c7b52408e700c33026c",
                "md5": "60677edf95aafc3579a6ceee7209b6b2",
                "sha256": "fa34371d8527846ed6cffec08fa8191fa70793af4442770333fb90d322693234"
            },
            "downloads": -1,
            "filename": "openweather_wrapper-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "60677edf95aafc3579a6ceee7209b6b2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12.0",
            "size": 11715,
            "upload_time": "2024-12-17T18:23:39",
            "upload_time_iso_8601": "2024-12-17T18:23:39.294610Z",
            "url": "https://files.pythonhosted.org/packages/27/d2/bdcb597e1d155baebf54172a8dbb28e23755fea00c7b52408e700c33026c/openweather_wrapper-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 18:23:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SHRISH01",
    "github_project": "openweather-wrapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "openweather-wrapper"
}
        
Elapsed time: 0.46443s