npm package: @sprintwerk/capacitor-weatherkit
Description: WeatherKit plugin for Capacitor
Author: Manuel Heidrich
Latest version: 1.0.1

# @sprintwerk/capacitor-weatherkit

Capacitor plugin for iOS to get current weather and weather forecast via Apple WeatherKit

## About this plugin

This Capacitor plugin provides native access to [Apple WeatherKit](https://developer.apple.com/weatherkit/), which has a generous free tier available. Make sure to follow [these instructions](https://developer.apple.com/documentation/weatherkit/fetching_weather_forecasts_with_weatherkit) to set up WeatherKit for your app.

### Android Support

This plugin is iOS only as WeatherKit natively is only available on iOS devices. However Apple offers a WeatherKit REST API which can be used on other platforms like Android and web. We are currently developing a NodeJS package ([@sprintwerk/node-weatherkit](https://github.com/sprintwerk/node-weatherkit)) that aims to provide easy access to the WeatherKit REST API while trying to maintain the same data schema as this Capacitor plugin returns. Check out [this repo](https://github.com/sprintwerk/node-weatherkit) and make sure to set `enableCapacitorPluginSchema` to `true` in the client config.

### Plugin author

This plugin is actively being developed and maintained by [Sprintwerk](https://sprintwerk.de/). We are experts in all things Ionic and Capacitor and provide tailored solutions from consulting to full stack development. Have a project? Need some support? Just drop us a line.

Pull requests, featrue requests or any constructive feedback for this plugin are always appreciated!

## Install

```bash
npm install @sprintwerk/capacitor-weatherkit
npx cap sync
```

## API

<docgen-index>

* [`getAvailability(...)`](#getavailability)
* [`getCurrentWeather(...)`](#getcurrentweather)
* [`getDailyForecast(...)`](#getdailyforecast)
* [Interfaces](#interfaces)
* [Enums](#enums)

</docgen-index>

<docgen-api>
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->

### getAvailability(...)

```typescript
getAvailability(options: { latitude: number; longitude: number; }) => Promise<WeatherAvailability>
```

Get weather data availability for a location

| Param         | Type                                                  | Description          |
| ------------- | ----------------------------------------------------- | -------------------- |
| **`options`** | <code>{ latitude: number; longitude: number; }</code> | Location coordinates |

**Returns:** <code>Promise&lt;<a href="#weatheravailability">WeatherAvailability</a>&gt;</code>

--------------------


### getCurrentWeather(...)

```typescript
getCurrentWeather(options: { latitude: number; longitude: number; }) => Promise<WeatherData>
```

Get current weather conditions for a location

| Param         | Type                                                  | Description          |
| ------------- | ----------------------------------------------------- | -------------------- |
| **`options`** | <code>{ latitude: number; longitude: number; }</code> | Location coordinates |

**Returns:** <code>Promise&lt;<a href="#weatherdata">WeatherData</a>&gt;</code>

--------------------


### getDailyForecast(...)

```typescript
getDailyForecast(options: { latitude: number; longitude: number; }) => Promise<{ forecast: DailyForecast[]; }>
```

Get daily forecast for a location

| Param         | Type                                                  | Description          |
| ------------- | ----------------------------------------------------- | -------------------- |
| **`options`** | <code>{ latitude: number; longitude: number; }</code> | Location coordinates |

**Returns:** <code>Promise&lt;{ forecast: DailyForecast[]; }&gt;</code>

--------------------


### Interfaces


#### WeatherAvailability

<a href="#weatheravailability">WeatherAvailability</a> represents the availability of data at the requested location. Weather alerts, or minute forecast data may be temporarily unavailable from the data provider, or unsupported in some regions. Other data sets are expected to be supported for all geographic locations, for example, current weather, and therefore are not included in <a href="#weatheravailability">WeatherAvailability</a>.

| Prop                     | Type                                                                        | Description                                |
| ------------------------ | --------------------------------------------------------------------------- | ------------------------------------------ |
| **`minuteAvailability`** | <code><a href="#weatheravailabilitykind">WeatherAvailabilityKind</a></code> | Availability of minute-by-minute forecasts |
| **`alertAvailability`**  | <code><a href="#weatheravailabilitykind">WeatherAvailabilityKind</a></code> | Availability of weather alerts             |


#### WeatherData

| Prop                         | Type                                                                  | Description                                  |
| ---------------------------- | --------------------------------------------------------------------- | -------------------------------------------- |
| **`apparentTemperature`**    | <code>number</code>                                                   | Temperature in Celsius                       |
| **`dewPoint`**               | <code>number</code>                                                   | Temperature in Celsius                       |
| **`humidity`**               | <code>number</code>                                                   | Relative humidity (0-1)                      |
| **`temperature`**            | <code>number</code>                                                   | Temperature in Celsius                       |
| **`pressure`**               | <code>number</code>                                                   | Pressure in hectopascals (hPa)               |
| **`pressureTrend`**          | <code><a href="#pressuretrendinfo">PressureTrendInfo</a></code>       |                                              |
| **`wind`**                   | <code><a href="#wind">Wind</a></code>                                 |                                              |
| **`cloudCover`**             | <code>number</code>                                                   | Cloud cover percentage (0-1)                 |
| **`cloudCoverByAltitude`**   | <code><a href="#cloudcoverbyaltitude">CloudCoverByAltitude</a></code> | Cloud cover by altitude (iOS 18+ only)       |
| **`condition`**              | <code><a href="#weatherdescription">WeatherDescription</a></code>     |                                              |
| **`date`**                   | <code>string</code>                                                   |                                              |
| **`isDaylight`**             | <code>boolean</code>                                                  |                                              |
| **`uvIndex`**                | <code><a href="#uvindex">UVIndex</a></code>                           |                                              |
| **`visibility`**             | <code>number</code>                                                   | Visibility in meters                         |
| **`metadata`**               | <code><a href="#weathermetadata">WeatherMetadata</a></code>           |                                              |
| **`symbolName`**             | <code>string</code>                                                   |                                              |
| **`precipitationIntensity`** | <code>number</code>                                                   | Precipitation intensity in meters per second |
| **`attribution`**            | <code><a href="#weatherattribution">WeatherAttribution</a></code>     | Attribution for the weather data             |


#### PressureTrendInfo

Pressure trend information

| Prop                           | Type                                                    |
| ------------------------------ | ------------------------------------------------------- |
| **`value`**                    | <code><a href="#pressuretrend">PressureTrend</a></code> |
| **`description`**              | <code>string</code>                                     |
| **`accessibilityDescription`** | <code>string</code>                                     |


#### Wind

<a href="#wind">Wind</a> data with speed, direction, and gust information

| Prop                   | Type                                                                  | Description                                               |
| ---------------------- | --------------------------------------------------------------------- | --------------------------------------------------------- |
| **`speed`**            | <code>number</code>                                                   | <a href="#wind">Wind</a> speed in meters per second (m/s) |
| **`compassDirection`** | <code><a href="#windcompassdirection">WindCompassDirection</a></code> |                                                           |
| **`direction`**        | <code>number</code>                                                   | <a href="#wind">Wind</a> direction in degrees (0-360)     |
| **`gust`**             | <code>number \| null</code>                                           | <a href="#wind">Wind</a> gust in meters per second (m/s)  |


#### WindCompassDirection

<a href="#wind">Wind</a> direction information

| Prop                           | Type                                                    |
| ------------------------------ | ------------------------------------------------------- |
| **`value`**                    | <code><a href="#winddirection">WindDirection</a></code> |
| **`abbreviation`**             | <code>string</code>                                     |
| **`description`**              | <code>string</code>                                     |
| **`accessibilityDescription`** | <code>string</code>                                     |


#### CloudCoverByAltitude

Cloud cover information by altitude

| Prop         | Type                | Description                       |
| ------------ | ------------------- | --------------------------------- |
| **`low`**    | <code>number</code> | Low altitude cloud cover (0-1)    |
| **`medium`** | <code>number</code> | Medium altitude cloud cover (0-1) |
| **`high`**   | <code>number</code> | High altitude cloud cover (0-1)   |


#### WeatherDescription

Describes a value with human-readable descriptions

| Prop                           | Type                |
| ------------------------------ | ------------------- |
| **`value`**                    | <code>string</code> |
| **`description`**              | <code>string</code> |
| **`accessibilityDescription`** | <code>string</code> |


#### UVIndex

UV index information

| Prop           | Type                                                        |
| -------------- | ----------------------------------------------------------- |
| **`value`**    | <code>number</code>                                         |
| **`category`** | <code><a href="#uvindexcategory">UVIndexCategory</a></code> |


#### WeatherMetadata

Metadata about the weather data

| Prop                 | Type                                                |
| -------------------- | --------------------------------------------------- |
| **`date`**           | <code>string</code>                                 |
| **`expirationDate`** | <code>string</code>                                 |
| **`location`**       | <code><a href="#coordinates">Coordinates</a></code> |


#### Coordinates

Location coordinates

| Prop            | Type                |
| --------------- | ------------------- |
| **`latitude`**  | <code>number</code> |
| **`longitude`** | <code>number</code> |


#### WeatherAttribution

Weather service attribution information

| Prop                      | Type                | Description                                  |
| ------------------------- | ------------------- | -------------------------------------------- |
| **`serviceName`**         | <code>string</code> | Name of the weather data provider            |
| **`legalPageUrl`**        | <code>string</code> | URL to the legal information page            |
| **`squareMarkUrl`**       | <code>string</code> | URL to the square mark image                 |
| **`combinedMarkDarkUrl`** | <code>string</code> | URL to the combined mark image for dark mode |


#### DailyForecast

| Prop                            | Type                                                                            | Description                                               |
| ------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------- |
| **`date`**                      | <code>number</code>                                                             |                                                           |
| **`highTemperature`**           | <code>number</code>                                                             | Temperature in Celsius                                    |
| **`lowTemperature`**            | <code>number</code>                                                             | Temperature in Celsius                                    |
| **`precipation`**               | <code><a href="#weatherdescription">WeatherDescription</a></code>               |                                                           |
| **`precipitationChance`**       | <code>number</code>                                                             | Precipitation chance (0-1)                                |
| **`precipitationAmountByType`** | <code><a href="#precipitationamountbytype">PrecipitationAmountByType</a></code> |                                                           |
| **`moon`**                      | <code><a href="#moondata">MoonData</a></code>                                   |                                                           |
| **`sun`**                       | <code><a href="#suntimes">SunTimes</a></code>                                   |                                                           |
| **`wind`**                      | <code><a href="#wind">Wind</a></code>                                           |                                                           |
| **`condition`**                 | <code><a href="#weatherdescription">WeatherDescription</a></code>               |                                                           |
| **`uvIndex`**                   | <code><a href="#uvindex">UVIndex</a></code>                                     |                                                           |
| **`symbolName`**                | <code>string</code>                                                             |                                                           |
| **`daytimeForecast`**           | <code><a href="#daypartforecast">DayPartForecast</a></code>                     | Daytime forecast (iOS 18+ only)                           |
| **`overnightForecast`**         | <code><a href="#daypartforecast">DayPartForecast</a></code>                     | Overnight forecast (iOS 18+ only)                         |
| **`restOfDayForecast`**         | <code><a href="#daypartforecast">DayPartForecast</a></code>                     | Rest of day forecast (iOS 18+ only)                       |
| **`highTemperatureTime`**       | <code>string</code>                                                             | High temperature time                                     |
| **`highWindSpeed`**             | <code>number</code>                                                             | <a href="#wind">Wind</a> speed in meters per second (m/s) |
| **`lowTemperatureTime`**        | <code>string</code>                                                             |                                                           |
| **`maximumHumidity`**           | <code>number</code>                                                             | Maximum relative humidity (0-1)                           |
| **`maximumVisibility`**         | <code>number</code>                                                             | Maximum visibility in meters                              |
| **`minimumHumidity`**           | <code>number</code>                                                             | Minimum relative humidity (0-1)                           |
| **`minimumVisibility`**         | <code>number</code>                                                             | Minimum visibility in meters                              |
| **`attribution`**               | <code><a href="#weatherattribution">WeatherAttribution</a></code>               | Attribution for the weather data                          |


#### PrecipitationAmountByType

Precipitation amounts by type

| Prop        | Type                                                        | Description                      |
| ----------- | ----------------------------------------------------------- | -------------------------------- |
| **`rain`**  | <code>number</code>                                         | Amount in millimeters            |
| **`snow`**  | <code><a href="#snowmeasurement">SnowMeasurement</a></code> | Snow measurements in millimeters |
| **`sleet`** | <code>number</code>                                         | Amount in millimeters            |
| **`hail`**  | <code>number</code>                                         | Amount in millimeters            |
| **`mixed`** | <code>number</code>                                         | Amount in millimeters            |
| **`total`** | <code>number</code>                                         | Total amount in millimeters      |


#### SnowMeasurement

Snow precipitation measurements

| Prop                          | Type                | Description                                             |
| ----------------------------- | ------------------- | ------------------------------------------------------- |
| **`amount`**                  | <code>number</code> | Current snow amount in millimeters                      |
| **`amountLiquidEquivalent`**  | <code>number</code> | Current liquid water equivalent in millimeters          |
| **`maximum`**                 | <code>number</code> | Maximum expected snow amount in millimeters             |
| **`maximumLiquidEquivalent`** | <code>number</code> | Maximum expected liquid water equivalent in millimeters |
| **`minimum`**                 | <code>number</code> | Minimum expected snow amount in millimeters             |
| **`minimumLiquidEquivalent`** | <code>number</code> | Minimum expected liquid water equivalent in millimeters |


#### MoonData

Moon phase and timing information

| Prop           | Type                        |
| -------------- | --------------------------- |
| **`moonRise`** | <code>string \| null</code> |
| **`moonSet`**  | <code>string \| null</code> |
| **`phase`**    | <code>string</code>         |


#### SunTimes

Astronomical data for sun positions

| Prop                   | Type                        |
| ---------------------- | --------------------------- |
| **`astronomicalDawn`** | <code>string \| null</code> |
| **`astronomicalDusk`** | <code>string \| null</code> |
| **`civilDawn`**        | <code>string \| null</code> |
| **`civilDusk`**        | <code>string \| null</code> |
| **`nauticalDawn`**     | <code>string \| null</code> |
| **`nauticalDusk`**     | <code>string \| null</code> |
| **`solarMidnight`**    | <code>string \| null</code> |
| **`solarNoon`**        | <code>string \| null</code> |
| **`sunrise`**          | <code>string \| null</code> |
| **`sunset`**           | <code>string \| null</code> |


#### DayPartForecast

| Prop                            | Type                                                                            | Description                                               |
| ------------------------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------- |
| **`cloudCover`**                | <code>number</code>                                                             | Cloud cover percentage (0-1)                              |
| **`cloudCoverByAltitude`**      | <code><a href="#cloudcoverbyaltitude">CloudCoverByAltitude</a></code>           | Cloud cover by altitude (iOS 18+ only)                    |
| **`condition`**                 | <code><a href="#weatherdescription">WeatherDescription</a></code>               | Condition                                                 |
| **`highTemperature`**           | <code>number</code>                                                             | Temperature in Celsius                                    |
| **`lowTemperature`**            | <code>number</code>                                                             | Temperature in Celsius                                    |
| **`highWindSpeed`**             | <code>number</code>                                                             | <a href="#wind">Wind</a> speed in meters per second (m/s) |
| **`maximumHumidity`**           | <code>number</code>                                                             | Maximum relative humidity (0-1)                           |
| **`maximumVisibility`**         | <code>number</code>                                                             | Maximum visibility in meters                              |
| **`minimumHumidity`**           | <code>number</code>                                                             | Minimum relative humidity (0-1)                           |
| **`minimumVisibility`**         | <code>number</code>                                                             | Minimum visibility in meters                              |
| **`precipitationChance`**       | <code>number</code>                                                             | Precipitation chance (0-1)                                |
| **`precipitation`**             | <code><a href="#weatherdescription">WeatherDescription</a></code>               |                                                           |
| **`precipitationAmountByType`** | <code><a href="#precipitationamountbytype">PrecipitationAmountByType</a></code> |                                                           |
| **`wind`**                      | <code><a href="#wind">Wind</a></code>                                           |                                                           |


### Enums


#### WeatherAvailabilityKind

| Members                      | Value                                 |
| ---------------------------- | ------------------------------------- |
| **`Available`**              | <code>'available'</code>              |
| **`TemporarilyUnavailable`** | <code>'temporarilyUnavailable'</code> |
| **`Unknown`**                | <code>'unknown'</code>                |
| **`Unsupported`**            | <code>'unsupported'</code>            |


#### PressureTrend

| Members       | Value                  |
| ------------- | ---------------------- |
| **`Falling`** | <code>"falling"</code> |
| **`Rising`**  | <code>"rising"</code>  |
| **`Steady`**  | <code>"steady"</code>  |


#### WindDirection

| Members              | Value                         |
| -------------------- | ----------------------------- |
| **`East`**           | <code>"east"</code>           |
| **`EastNortheast`**  | <code>"eastNortheast"</code>  |
| **`EastSoutheast`**  | <code>"eastSoutheast"</code>  |
| **`North`**          | <code>"north"</code>          |
| **`NorthNortheast`** | <code>"northNortheast"</code> |
| **`NorthNorthwest`** | <code>"northNorthwest"</code> |
| **`Northeast`**      | <code>"northeast"</code>      |
| **`Northwest`**      | <code>"northwest"</code>      |
| **`South`**          | <code>"south"</code>          |
| **`SouthSoutheast`** | <code>"southSoutheast"</code> |
| **`SouthSouthwest`** | <code>"southSouthwest"</code> |
| **`Southeast`**      | <code>"southeast"</code>      |
| **`Southwest`**      | <code>"southwest"</code>      |
| **`West`**           | <code>"west"</code>           |
| **`WestNorthwest`**  | <code>"westNorthwest"</code>  |
| **`WestSouthwest`**  | <code>"westSouthwest"</code>  |


#### UVIndexCategory

| Members        | Value                   |
| -------------- | ----------------------- |
| **`Extreme`**  | <code>"extreme"</code>  |
| **`VeryHigh`** | <code>"veryHigh"</code> |
| **`High`**     | <code>"high"</code>     |
| **`Moderate`** | <code>"moderate"</code> |
| **`Low`**      | <code>"low"</code>      |

</docgen-api>