PyWeatherKit


NamePyWeatherKit JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummaryA Python wrapper for the WeatherKit API
upload_time2023-04-05 12:36:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords weather kit weatherkit api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyWeatherKit
A simple Python wrapper for [Apple's WeatherKit REST API](https://developer.apple.com/documentation/weatherkitrestapi).

You need an Apple developer account to use this library and you should first follow the [setup instructions](https://developer.apple.com/documentation/weatherkitrestapi/request_authentication_for_weatherkit_rest_api) in their documentation.

It has a simple interface for retrieving a raw dictionary of weather data from the API, and a method for retrieving simplified daily forecasts as Pythonic objects. Pull requests are welcome!

## Install

```bash
pip install pyweatherkit
```

## Simple Forecast Usage

```python
from weatherkit.client import WKClient 
client = WKClient("YOUR TEAM ID", "YOUR SERVICE ID", "YOUR KEY ID", "PATH TO YOUR PRIVATE KEY FILE")
forecast = client.get_simple_forecast(latitude, longitude)
for day in forecast:
    print(f"{day.day_of_week}: {day.daytime_icon} with a high of {round(day.temperature_high)} and a low of {round(day.temperature_low)}")
```

Assuming you input all of the correct client authentication parameters and a valid latitude and longitude, this should result in something like:

```bash
Thursday: 🌤️ with a high of 38 and a low of 23
Friday: 🌧️ with a high of 45 and a low of 22
Saturday: 🌧️ with a high of 67 and a low of 40
...
```

## Pulling Full Data Sets

```python
from weatherkit.client import WKClient 
client = WKClient("YOUR TEAM ID", "YOUR SERVICE ID", "YOUR KEY ID", "PATH TO YOUR PRIVATE KEY FILE")
res = client.get_weather(44.50572, -73.24026)
```

You can also specify the language of the response, the timezone, and the specific datasets you need.

### Historical Data Pull 
Only available from dates after 08/01/2021 (as of 2023-03-23)
```python
from weatherkit.client import WKClient
from datetime import datetime

# Set dates 
dailyStart = datetime.strptime("2022-11-29", "%Y-%m-%d")
dailyEnd = datetime.strptime("2022-11-30", "%Y-%m-%d")
currentAsOf = datetime.strptime("2022-11-29", "%Y-%m-%d")

client = WKClient("YOUR TEAM ID", "YOUR SERVICE ID", "YOUR KEY ID", "PATH TO YOUR PRIVATE KEY FILE")
res = client.get_weather(44.50572, -73.24026, dailyStart=dailyStart, dailyEnd=dailyEnd, currentAsOf=currentAsOf)
```

## Test/Example Program

Try running simple_test.py from the same directory as this package.

```bash
python3 simple_test.py your_team_id your_service_id your_key_id your_key_path your_latitude your_longitude
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PyWeatherKit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "weather,kit,weatherkit,api",
    "author": null,
    "author_email": "David Kopec <david@oaksnow.com>",
    "download_url": "https://files.pythonhosted.org/packages/0e/58/a30e1fab3ac45f8ee01dafecb4f9ba649900a7e0933b17006cf43635d65f/PyWeatherKit-0.0.4.tar.gz",
    "platform": null,
    "description": "# PyWeatherKit\nA simple Python wrapper for [Apple's WeatherKit REST API](https://developer.apple.com/documentation/weatherkitrestapi).\n\nYou need an Apple developer account to use this library and you should first follow the [setup instructions](https://developer.apple.com/documentation/weatherkitrestapi/request_authentication_for_weatherkit_rest_api) in their documentation.\n\nIt has a simple interface for retrieving a raw dictionary of weather data from the API, and a method for retrieving simplified daily forecasts as Pythonic objects. Pull requests are welcome!\n\n## Install\n\n```bash\npip install pyweatherkit\n```\n\n## Simple Forecast Usage\n\n```python\nfrom weatherkit.client import WKClient \nclient = WKClient(\"YOUR TEAM ID\", \"YOUR SERVICE ID\", \"YOUR KEY ID\", \"PATH TO YOUR PRIVATE KEY FILE\")\nforecast = client.get_simple_forecast(latitude, longitude)\nfor day in forecast:\n    print(f\"{day.day_of_week}: {day.daytime_icon} with a high of {round(day.temperature_high)} and a low of {round(day.temperature_low)}\")\n```\n\nAssuming you input all of the correct client authentication parameters and a valid latitude and longitude, this should result in something like:\n\n```bash\nThursday: \ud83c\udf24\ufe0f with a high of 38 and a low of 23\nFriday: \ud83c\udf27\ufe0f with a high of 45 and a low of 22\nSaturday: \ud83c\udf27\ufe0f with a high of 67 and a low of 40\n...\n```\n\n## Pulling Full Data Sets\n\n```python\nfrom weatherkit.client import WKClient \nclient = WKClient(\"YOUR TEAM ID\", \"YOUR SERVICE ID\", \"YOUR KEY ID\", \"PATH TO YOUR PRIVATE KEY FILE\")\nres = client.get_weather(44.50572, -73.24026)\n```\n\nYou can also specify the language of the response, the timezone, and the specific datasets you need.\n\n### Historical Data Pull \nOnly available from dates after 08/01/2021 (as of 2023-03-23)\n```python\nfrom weatherkit.client import WKClient\nfrom datetime import datetime\n\n# Set dates \ndailyStart = datetime.strptime(\"2022-11-29\", \"%Y-%m-%d\")\ndailyEnd = datetime.strptime(\"2022-11-30\", \"%Y-%m-%d\")\ncurrentAsOf = datetime.strptime(\"2022-11-29\", \"%Y-%m-%d\")\n\nclient = WKClient(\"YOUR TEAM ID\", \"YOUR SERVICE ID\", \"YOUR KEY ID\", \"PATH TO YOUR PRIVATE KEY FILE\")\nres = client.get_weather(44.50572, -73.24026, dailyStart=dailyStart, dailyEnd=dailyEnd, currentAsOf=currentAsOf)\n```\n\n## Test/Example Program\n\nTry running simple_test.py from the same directory as this package.\n\n```bash\npython3 simple_test.py your_team_id your_service_id your_key_id your_key_path your_latitude your_longitude\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python wrapper for the WeatherKit API",
    "version": "0.0.4",
    "split_keywords": [
        "weather",
        "kit",
        "weatherkit",
        "api"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0a213d83b18836193ed7d515beef6f14d9b2c946cd80b09b9e452f4f77b64a2a",
                "md5": "c25a10710b04cb2129e1f076a31c2aed",
                "sha256": "71d07f0bdc72946c82ab00c988aedfc8729d2c30b0a43bdf3e6a7a7f66386ac7"
            },
            "downloads": -1,
            "filename": "pyweatherkit-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c25a10710b04cb2129e1f076a31c2aed",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 11316,
            "upload_time": "2023-04-05T12:35:54",
            "upload_time_iso_8601": "2023-04-05T12:35:54.795755Z",
            "url": "https://files.pythonhosted.org/packages/0a/21/3d83b18836193ed7d515beef6f14d9b2c946cd80b09b9e452f4f77b64a2a/pyweatherkit-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0e58a30e1fab3ac45f8ee01dafecb4f9ba649900a7e0933b17006cf43635d65f",
                "md5": "134ea9232a8b2341495d1c4b9c380c10",
                "sha256": "86810e30df68084a85fc262c60290c2b16a89fcccc98de985228659b84ea6dc9"
            },
            "downloads": -1,
            "filename": "PyWeatherKit-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "134ea9232a8b2341495d1c4b9c380c10",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 11706,
            "upload_time": "2023-04-05T12:36:01",
            "upload_time_iso_8601": "2023-04-05T12:36:01.318057Z",
            "url": "https://files.pythonhosted.org/packages/0e/58/a30e1fab3ac45f8ee01dafecb4f9ba649900a7e0933b17006cf43635d65f/PyWeatherKit-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-05 12:36:01",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "pyweatherkit"
}
        
Elapsed time: 0.81603s