PHPackages                             mobiadroit/laravel-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. mobiadroit/laravel-weatherkit

ActiveLibrary[API Development](/categories/api)

mobiadroit/laravel-weatherkit
=============================

Provides a Wrapper for the Apple WeatherKit API

1.1(1y ago)075MITPHPPHP &gt;=7.4.0

Since Jan 6Pushed 1y agoCompare

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

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

Laravel WeatherKit
==================

[](#laravel-weatherkit)

This provides a Laravel style wrapper for Apple's WeatherKit api, which replaced the DarkSky API.

For more information see

Please note, Apple requires attribution to use this API in your code  and up to 500,000 calls/month are included with your apple developer account membership.

Install
-------

[](#install)

Require this package with composer using the following command:

```
$ composer require mobiadroit/laravel-weatherkit
```

### Providers

[](#providers)

This library works out-of-the-box with Laravel's Service Providers and will be loaded automatically in Laravel `>= 5.5`.

You can, of course, add it manually to your `providers` array in `config/app.php` if you'd prefer

```
'providers' => [
    Mobiadroit\LaravelWeatherKit\Providers\LaravelServiceProvider::class,
]
```

### Facade

[](#facade)

To register a facade accessor, add the following to `config/app.php` `aliases` array

```
'aliases' => [
    'WeatherKit' => Mobiadroit\LaravelWeatherKit\Facades\WeatherKit::class,
]
```

### Configuration

[](#configuration)

See [Authentication](#Authentication) section on how to use these environment variables.

Variable nameDefaultDescription`WEATHERKIT_AUTH_TYPE``jwt``jwt` or `p8` token generation----------------------------------------------------------------------------------------------`WEATHERKIT_JWT_TOKEN`A pre-generated JWT token.----------------------------------------------------------------------------------------------`WEATHERKIT_KEY`Path to the `.p8` key file or key as a string`WEATHERKIT_KEY_ID`Key ID for you `.p8` file`WEATHERKIT_TEAM_ID`Your Apple Team ID`WEATHERKIT_BUNDLE_ID`Bundle ID of your App`WEATHERKIT_TOKEN_TTL``3600`Expiry time of token in seconds----------------------------------------------------------------------------------------------`WEATHERKIT_LANGUAGE_CODE``config('app.locale', 'en')`Language code`WEATHERKIT_TIMEZONE``config('app.timezone', 'UTC')`Timezone for timestampsIf you wish to change the default configuration, you can publish the configuration file to your project.

```
$ php artisan vendor:publish --provider=\Mobiadroit\LaravelWeatherKit\Providers\LaravelServiceProvider
```

Authentication
--------------

[](#authentication)

There are two ways to authenticate with WeatherKit using this library. You'll need to generate the key file first for whichever method you choose.

### Generate Key File

[](#generate-key-file)

If you wish to generate and manage your own JWT Token yourself then you'll need to first generate a JWT token to access WeatherKit APIs.

You'll need to be enrolled in the paid Apple Developer Program, and register a new App ID and create a key.

#### Create new App ID

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

Create an App Identifier on the [Identifiers](https://developer.apple.com/account/resources/identifiers/list) section of your account. Enter a short description and give your app a unique bundle ID (e.g. com.myapp.weather).

Make sure you check the WeatherKit option under *BOTH* the Capabilities and App Services tabs. Click on Continue.

#### Create a Key

[](#create-a-key)

Go to the [Keys](https://developer.apple.com/account/resources/authkeys/list) page in your developer account.

Give the key a name, e.g. WeatherKit, and make sure to enable WeatherKit. Then click the Continue button. Then you'll be taken to a page with a Register button.

Remember to download the key file you get at the end!

#### Required Information

[](#required-information)

Whichever authentication method you decide to use, we are going to need some additional information first.

- You Apple Team ID
- The App Bundle ID that you created earlier (reverse DNS).
- The Key ID of the key, that you created in the Create new key section, you can get this at any point after generation.
- The physical key file ending in `.p8` you downloaded.

### Manual JWT Token Generation

[](#manual-jwt-token-generation)

Once you've generated and downloaded your `.p8` key file above, we now need to generate your JWT token and public/private keys

Create your private key in a PEM format using `openssl`

`openssl pkcs8 -nocrypt -in AuthKey_ABC1235XS.p8 -out AuthKey_ABC1235XS.pem`

*Note:* the option `-nocrypt` is required!

A public key is also required for signing JWT tokens

`openssl ec -in AuthKey_ABC1235XS.pem -pubout > AuthKey_ABC1235XS.pub`

You should now have two files, a public and a private key. These will be used to sign your JWT token.

Use a JWT token generator such as

For the header you want

```
{
  "alg": "ES256",
  "kid": "",
  "id": "."
}
```

The payload

```
{
  "iss": "",
  "iat": ,
  "exp": ,
  "sub": ""
}
```

E.g.

```
{
  "alg": "ES256",
  "kid": "ABC1234567",
  "id": "DEV1234567.com.myapp.weather"
},
{
  "iss": "DEV1234567",
  "iat": 1670851291,
  "exp": 1702385664,
  "sub": "com.myapp.weather"
}
```

Copy and paste your private and public key into the signature verification, and the output is what you need to add to your configuration `WEATHERKIT_JWT_TOKEN`.

#### Configuration

[](#configuration-1)

Add the following lines to the .env file:

```
WEATHERKIT_AUTH_TYPE=jwt
WEATHERKIT_JWT_TOKEN=
```

### Dynamic Token Generation

[](#dynamic-token-generation)

Starting with library version `>=1.2` you can dynamically generate your JWT token direct

#### Configuration

[](#configuration-2)

Add the following lines to the .env file:

```
WEATHERKIT_AUTH_TYPE=p8
WEATHERKIT_KEY=
WEATHERKIT_KEY_ID=
WEATHERKIT_TEAM_ID=
WEATHERKIT_BUNDLE_ID=
```

Usage
-----

[](#usage)

For full details of response formats, visit: [https://developer.apple.com/documentation/weatherkitrestapi/get\_api\_v1\_weather\_language\_latitude\_longitude](https://developer.apple.com/documentation/weatherkitrestapi/get_api_v1_weather_language_latitude_longitude)

There are two endpoints available at present, availability and weather.

Availability allows you to retrieve which data sets are available for a given location. If you call the availability function before the weather one, we will automatically set the requested datasets to this available.

`availability()` and `weather()` functions will return their results as a Laravel `Collection`

### Required

[](#required)

#### location(lat, lon)

[](#locationlat-lon)

Pass in latitude and longitude coordinates for a basic response

```
WeatherKit::location(lat, lon)->weather();
```

### Optional Parameters

[](#optional-parameters)

#### language(lang)

[](#languagelang)

Pass in a language code to return text based responses in the requested language. By default this is `en_US`

```
WeatherKit::lang('en_GB')->location(lat, lon)->weather();
```

#### dataSets(\[\])

[](#datasets)

Specify which data sets to use to reduce data transfer.

By default we will try to call `'currentWeather', 'forecastDaily', 'forecastHourly', 'forecastNextHour'`, however you can set these manually with `dataSets()` function. You can also dynamically set this by calling `availability()` before `weather()` when not using through a facade.

```
WeatherKit::location(lat, lon)->dataSets(['currentWeather', 'forecastDaily'])->weather();

// OR

$weather = new \Mobiadroit\LaravelWeatherKit\WeatherKit();
$weather->location(lat, lon)->availability();
$weather->location(lat, lon)->weather();
```

#### currentAsOf(t)

[](#currentasoft)

Pass in a Carbon object of time to obtain current conditions. Defaults to now.

```
WeatherKit::location(lat, lon)->currentAsOf(now())->weather();
```

#### dailyStart(t)/dailyEnd(t)

[](#dailystarttdailyendt)

`dailyStart()`: The time to start the daily forecast. If this parameter is absent, daily forecasts start on the current day. `dailyEnd()`: The time to end the daily forecast. If this parameter is absent, daily forecasts run for 10 days.

```
WeatherKit::location(lat, lon)->dailyStart(now()->subDays(7))->dailyEnd(now())->weather();
```

#### hourlyStart(t)/hourlyEnd(t)

[](#hourlystartthourlyendt)

`hourlyStart()`: The time to start the hourly forecast. If this parameter is absent, hourly forecasts start on the current hour. `hourlyEnd()`: The time to end the hourly forecast. If this parameter is absent, hourly forecasts run 24 hours or the length of the daily forecast, whichever is longer.

```
WeatherKit::location(lat, lon)->hourlyStart(now()->subHours(24))->hourlyEnd(now())->weather();
```

#### timezone(timezone)

[](#timezonetimezone)

The name of the timezone to use for rolling up weather forecasts into daily forecasts. Defaults to unset, as this is not required unless calling daily forecasts

```
WeatherKit::location(lat, lon)->timezone('Americas/Los_Angeles')->weather();
```

### Helpers

[](#helpers)

The following are shorthand helpers to add readability equivalent to using `dataSets` set to a single object.

```
->currently()
->hourly()
->daily()
->nextHour()
```

For example, these two statements are the same

```
WeatherKit::location(lat, lon)->hourly()
WeatherKit::location(lat, lon)->dataSets(['forecastHourly'])->weather()->get('forecastHourly')
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance46

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~456 days

Total

2

Last Release

401d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6dbc8d6a1fe63946ddfbf86db52116ca0ca90a9fddcff25f8b4120574e85e0dc?d=identicon)[blakekrone](/maintainers/blakekrone)

---

Top Contributors

[![Rich2k](https://avatars.githubusercontent.com/u/194617?v=4)](https://github.com/Rich2k "Rich2k (11 commits)")[![blakekrone](https://avatars.githubusercontent.com/u/5911342?v=4)](https://github.com/blakekrone "blakekrone (9 commits)")

---

Tags

weatherforecastweather forecastweatherkitapple weatherkitweatherkit apiapple weatherkit apilaravel-weatherkitmobiadroit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mobiadroit-laravel-weatherkit/health.svg)

```
[![Health](https://phpackages.com/badges/mobiadroit-laravel-weatherkit/health.svg)](https://phpackages.com/packages/mobiadroit-laravel-weatherkit)
```

###  Alternatives

[rugaard/weatherkit

Integrate Apple WeatherKit API into your project

111.4k](/packages/rugaard-weatherkit)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[vemcogroup/laravel-weather

Weather package for Laravel to use different providers to get weather info

5525.0k](/packages/vemcogroup-laravel-weather)[adinan-cenci/climatempo-api

Uma api para previsão de tempo escrita em PHP.

448.2k](/packages/adinan-cenci-climatempo-api)[gnahotelsolutions/laravel-weather

🌤️ A wrapper around Open Weather Map to get the current weather on a location.

385.3k](/packages/gnahotelsolutions-laravel-weather)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
