PHPackages                             rugaard/weatherkit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rugaard/weatherkit

ActiveLibrary[API Development](/categories/api)

rugaard/weatherkit
==================

Integrate Apple WeatherKit API into your project

0.1.1(2y ago)111.4k7[1 PRs](https://github.com/rugaard/weatherkit/pulls)MITPHPPHP ^8.1

Since Sep 5Pushed 2y ago2 watchersCompare

[ Source](https://github.com/rugaard/weatherkit)[ Packagist](https://packagist.org/packages/rugaard/weatherkit)[ Docs](https://github.com/rugaard)[ RSS](/packages/rugaard-weatherkit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

[![Banner](https://camo.githubusercontent.com/a39eb39dfc07ae9124fd5bdbc33e8fef98a147e8286a837bc76e5d6cbe104107/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f576561746865724b69742e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d72756761617264253246776561746865726b6974267061747465726e3d746f706f677261706879267374796c653d7374796c655f31266465736372697074696f6e3d4765742b6c61746573742b776561746865722b666f726563617374732b616e642b616c657274732b66726f6d2b4170706c652b576561746865724b69742b4150492e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313235707826696d616765733d73756e)](https://camo.githubusercontent.com/a39eb39dfc07ae9124fd5bdbc33e8fef98a147e8286a837bc76e5d6cbe104107/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f576561746865724b69742e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d72756761617264253246776561746865726b6974267061747465726e3d746f706f677261706879267374796c653d7374796c655f31266465736372697074696f6e3d4765742b6c61746573742b776561746865722b666f726563617374732b616e642b616c657274732b66726f6d2b4170706c652b576561746865724b69742b4150492e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313235707826696d616765733d73756e)[![PHP 8.1](https://camo.githubusercontent.com/ac4fa9d93f3eac34f2430f72bbb7c54f7a132c91ca9112b2ba403aae0c3c8d72/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312d626c7565)](https://camo.githubusercontent.com/ac4fa9d93f3eac34f2430f72bbb7c54f7a132c91ca9112b2ba403aae0c3c8d72/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e312d626c7565) [![Coding style](https://github.com/rugaard/weatherkit/actions/workflows/coding-style.yaml/badge.svg)](https://github.com/rugaard/weatherkit/actions/workflows/coding-style.yaml) [![Tests](https://github.com/rugaard/weatherkit/actions/workflows/tests.yaml/badge.svg)](https://github.com/rugaard/weatherkit/actions/workflows/tests.yaml) [![Coverage](https://camo.githubusercontent.com/3e3cfffe1e6b0291a02d961b01399092451d26b36d28c323410ffeba1c107a7f/68747470733a2f2f636f6465636f762e696f2f67682f727567616172642f776561746865726b69742f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d5a4d4841344555544d34)](https://codecov.io/gh/rugaard/weatherkit) [![License](https://camo.githubusercontent.com/f0eadc6f627ce2be3902b46237235c46984e30d7f21536697de02c2aaa4f2a87/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f727567616172642f776561746865726b69743f)](https://camo.githubusercontent.com/f0eadc6f627ce2be3902b46237235c46984e30d7f21536697de02c2aaa4f2a87/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f727567616172642f776561746865726b69743f)

#### ⚠️ DISCLAIMER ⚠️

[](#️-disclaimer-️)

*Apple's WeatherKit REST API is currently still in beta and the documentation is not fully up-to-date.*

*During development undocumented responses and values were encountered, but have been handled to the best of what information was available at the time.*

📖 Table of contents
-------------------

[](#-table-of-contents)

- [Features](#-features)
- [Installation](#-installation)
    - [Laravel provider](#laravel-provider)
- [Authentication](#-authentication)
    - [Create new App ID](#create-new-app-id)
    - [Create new key](#create-new-key)
- [Usage](#%EF%B8%8F-usage)
    - [Generate access token](#generate-access-token)
    - [Standalone](#standalone)
    - [With Laravel](#with-laravel)
- [Documentation](#-documentation)
- [License](#-license)

🚀 Features
----------

[](#-features)

- **Multiple forecast types**
    - Current weather
    - Next hour (minute-by-minute) forecast 🔹
    - Hourly forecast
    - Daily forecast
- **Weather alerts** 🔸
- **Built-in unit conversions**
    - Length
    - Pressure
    - Speed
    - Temperature

*🔹 = In countries where available.**🔸 = When a country code is provided.*

📦 Installation
--------------

[](#-installation)

You can install the package via [Composer](https://getcomposer.org/), by using the following command:

```
composer require rugaard/weatherkit
```

### Laravel provider

[](#laravel-provider)

This package comes with a out-of-the-box Service Provider for the [Laravel](http://laravel.com) framework. If you're using a newer version of Laravel (`>= 5.5`) then the service provider will loaded automatically.

Are you using an older version, then you need to manually add the service provider to the `config/app.php` file:

```
'providers' => [
    Rugaard\WeatherKit\Providers\LaravelServiceProvider::class,
]
```

#### Configuration

[](#configuration)

The default package configuration are setup to use the following environment variables.

Variable nameDefaultDescription`RUGAARD_WEATHERKIT_AUTH_FILEPATH`Path to the `.p8` key file.`RUGAARD_WEATHERKIT_AUTH_KEY_ID`Key ID matching the `.p8` key file`RUGAARD_WEATHERKIT_AUTH_APP_PREFIX_ID`App Prefix ID (aka. Team ID)`RUGAARD_WEATHERKIT_AUTH_BUNDLE_ID`Bundle ID of your App ID.`RUGAARD_WEATHERKIT_LANGUAGE_CODE``config('app.locale', 'en')`Language code`RUGAARD_WEATHERKIT_TIMEZONE``config('app.timezone', 'UTC')`Set timezone of timestampsShould you need to change the default configuration, you can publish the configuration file to your project.

```
php artisan vendor:publish --provider=\Rugaard\WeatherKit\Providers\LaravelServiceProvider
```

🔑 Authentication
----------------

[](#-authentication)

After Apple bought [DarkSky](https://blog.darksky.net/) and turned into [WeatherKit](https://developer.apple.com/weatherkit/), the API now requires authentication. To be able to authenticate, you are required to be part of [Apple's Developer Program](https://developer.apple.com/programs/).

Once you're enrolled with Apple Developer Program, you must register a new **App ID** and create a new **Key**.

### Create new App ID

[](#create-new-app-id)

To create a new App ID, you must [register your app on this form](https://developer.apple.com/account/resources/identifiers/bundleId/add/bundle). Enter a short description and give your app a unique bundle ID (reverse url).

**Example:**

DescriptionBundle IDLatest weather forecast`com.forecast.weather`When you are done filling out the required fields, you need **☑️ WeatherKit** under the **Capabilities** and **App Services** tabs.

Afterwards, click the blue **Continue** button and you're done.

### Create new key

[](#create-new-key)

To create a new key, you must [generate it from this form](https://developer.apple.com/account/resources/authkeys/add).

Give your key a name and make sure to enable **☑️ WeatherKit**. When you're done, click the blue **Continue** button. You'll be redirected to a confirmation page, where you click the blue **Register** button.

Then, download your key as physical file to your machine. It's required for authenticating with the API.

And that's it. You're done.

⚙️ Usage
--------

[](#️-usage)

Before the client can be instantiated, it requires an access token. To generate an access token, Apple requires you to create an App ID and Key, which you to download as a physical file.

If you have not done these things yet, you can follow the guide in the [🔑 Authentication](#-authentication) section of this README.

### Generate access token

[](#generate-access-token)

To generate an access token, you're going to need a few things:

- The `App ID Prefix` and `Bundle ID` that you created in [Create new App ID](#create-new-app-id) section.
- The `Key ID` of the key, that you created in the [Create new key](#create-new-key) section.
- The physical key you downloaded in the [Create new key](#create-new-key) section.

```
