@sprintwerk/capacitor-weatherkit v1.0.0
@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, which has a generous free tire available. Make sure to follow these instructions 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) 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 and make sure to set enableCapacitorPluginSchema
to true
in the client config.
Plugin author
This plugin is actively being developed and maintained by Sprintwerk. 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
npm install @sprintwerk/capacitor-weatherkit
npx cap sync
API
getAvailability(...)
getAvailability(options: { latitude: number; longitude: number; }) => Promise<WeatherAvailability>
Get weather data availability for a location
Param | Type | Description |
---|---|---|
options | { latitude: number; longitude: number; } | Location coordinates |
Returns: Promise<WeatherAvailability>
getCurrentWeather(...)
getCurrentWeather(options: { latitude: number; longitude: number; }) => Promise<WeatherData>
Get current weather conditions for a location
Param | Type | Description |
---|---|---|
options | { latitude: number; longitude: number; } | Location coordinates |
Returns: Promise<WeatherData>
getDailyForecast(...)
getDailyForecast(options: { latitude: number; longitude: number; }) => Promise<{ forecast: DailyForecast[]; }>
Get daily forecast for a location
Param | Type | Description |
---|---|---|
options | { latitude: number; longitude: number; } | Location coordinates |
Returns: Promise<{ forecast: DailyForecast[]; }>
Interfaces
WeatherAvailability
WeatherAvailability 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 WeatherAvailability.
Prop | Type | Description |
---|---|---|
minuteAvailability | WeatherAvailabilityKind | Availability of minute-by-minute forecasts |
alertAvailability | WeatherAvailabilityKind | Availability of weather alerts |
WeatherData
Prop | Type | Description |
---|---|---|
apparentTemperature | number | Temperature in Celsius |
dewPoint | number | Temperature in Celsius |
humidity | number | Relative humidity (0-1) |
temperature | number | Temperature in Celsius |
pressure | number | Pressure in hectopascals (hPa) |
pressureTrend | PressureTrendInfo | |
wind | Wind | |
cloudCover | number | Cloud cover percentage (0-1) |
cloudCoverByAltitude | CloudCoverByAltitude | Cloud cover by altitude (iOS 18+ only) |
condition | WeatherDescription | |
date | string | |
isDaylight | boolean | |
uvIndex | UVIndex | |
visibility | number | Visibility in meters |
metadata | WeatherMetadata | |
symbolName | string | |
precipitationIntensity | number | Precipitation intensity in meters per second |
attribution | WeatherAttribution | Attribution for the weather data |
PressureTrendInfo
Pressure trend information
Prop | Type |
---|---|
value | PressureTrend |
description | string |
accessibilityDescription | string |
Wind
Wind data with speed, direction, and gust information
Prop | Type | Description |
---|---|---|
speed | number | Wind speed in meters per second (m/s) |
compassDirection | WindCompassDirection | |
direction | number | Wind direction in degrees (0-360) |
gust | number | null | Wind gust in meters per second (m/s) |
WindCompassDirection
Wind direction information
Prop | Type |
---|---|
value | WindDirection |
abbreviation | string |
description | string |
accessibilityDescription | string |
CloudCoverByAltitude
Cloud cover information by altitude
Prop | Type | Description |
---|---|---|
low | number | Low altitude cloud cover (0-1) |
medium | number | Medium altitude cloud cover (0-1) |
high | number | High altitude cloud cover (0-1) |
WeatherDescription
Describes a value with human-readable descriptions
Prop | Type |
---|---|
value | string |
description | string |
accessibilityDescription | string |
UVIndex
UV index information
Prop | Type |
---|---|
value | number |
category | UVIndexCategory |
WeatherMetadata
Metadata about the weather data
Prop | Type |
---|---|
date | string |
expirationDate | string |
location | Coordinates |
Coordinates
Location coordinates
Prop | Type |
---|---|
latitude | number |
longitude | number |
WeatherAttribution
Weather service attribution information
Prop | Type | Description |
---|---|---|
serviceName | string | Name of the weather data provider |
legalPageUrl | string | URL to the legal information page |
squareMarkUrl | string | URL to the square mark image |
combinedMarkDarkUrl | string | URL to the combined mark image for dark mode |
DailyForecast
Prop | Type | Description |
---|---|---|
date | number | |
highTemperature | number | Temperature in Celsius |
lowTemperature | number | Temperature in Celsius |
precipation | WeatherDescription | |
precipitationChance | number | Precipitation chance (0-1) |
precipitationAmountByType | PrecipitationAmountByType | |
moon | MoonData | |
sun | SunTimes | |
wind | Wind | |
condition | WeatherDescription | |
uvIndex | UVIndex | |
symbolName | string | |
daytimeForecast | DayPartForecast | Daytime forecast (iOS 18+ only) |
overnightForecast | DayPartForecast | Overnight forecast (iOS 18+ only) |
restOfDayForecast | DayPartForecast | Rest of day forecast (iOS 18+ only) |
highTemperatureTime | string | High temperature time |
highWindSpeed | number | Wind speed in meters per second (m/s) |
lowTemperatureTime | string | |
maximumHumidity | number | Maximum relative humidity (0-1) |
maximumVisibility | number | Maximum visibility in meters |
minimumHumidity | number | Minimum relative humidity (0-1) |
minimumVisibility | number | Minimum visibility in meters |
attribution | WeatherAttribution | Attribution for the weather data |
PrecipitationAmountByType
Precipitation amounts by type
Prop | Type | Description |
---|---|---|
rain | number | Amount in millimeters |
snow | SnowMeasurement | Snow measurements in millimeters |
sleet | number | Amount in millimeters |
hail | number | Amount in millimeters |
mixed | number | Amount in millimeters |
total | number | Total amount in millimeters |
SnowMeasurement
Snow precipitation measurements
Prop | Type | Description |
---|---|---|
amount | number | Current snow amount in millimeters |
amountLiquidEquivalent | number | Current liquid water equivalent in millimeters |
maximum | number | Maximum expected snow amount in millimeters |
maximumLiquidEquivalent | number | Maximum expected liquid water equivalent in millimeters |
minimum | number | Minimum expected snow amount in millimeters |
minimumLiquidEquivalent | number | Minimum expected liquid water equivalent in millimeters |
MoonData
Moon phase and timing information
Prop | Type |
---|---|
moonRise | string | null |
moonSet | string | null |
phase | string |
SunTimes
Astronomical data for sun positions
Prop | Type |
---|---|
astronomicalDawn | string | null |
astronomicalDusk | string | null |
civilDawn | string | null |
civilDusk | string | null |
nauticalDawn | string | null |
nauticalDusk | string | null |
solarMidnight | string | null |
solarNoon | string | null |
sunrise | string | null |
sunset | string | null |
DayPartForecast
Prop | Type | Description |
---|---|---|
cloudCover | number | Cloud cover percentage (0-1) |
cloudCoverByAltitude | CloudCoverByAltitude | Cloud cover by altitude (iOS 18+ only) |
condition | WeatherDescription | Condition |
highTemperature | number | Temperature in Celsius |
lowTemperature | number | Temperature in Celsius |
highWindSpeed | number | Wind speed in meters per second (m/s) |
maximumHumidity | number | Maximum relative humidity (0-1) |
maximumVisibility | number | Maximum visibility in meters |
minimumHumidity | number | Minimum relative humidity (0-1) |
minimumVisibility | number | Minimum visibility in meters |
precipitationChance | number | Precipitation chance (0-1) |
precipitation | WeatherDescription | |
precipitationAmountByType | PrecipitationAmountByType | |
wind | Wind |
Enums
WeatherAvailabilityKind
Members | Value |
---|---|
Available | 'available' |
TemporarilyUnavailable | 'temporarilyUnavailable' |
Unknown | 'unknown' |
Unsupported | 'unsupported' |
PressureTrend
Members | Value |
---|---|
Falling | "falling" |
Rising | "rising" |
Steady | "steady" |
WindDirection
Members | Value |
---|---|
East | "east" |
EastNortheast | "eastNortheast" |
EastSoutheast | "eastSoutheast" |
North | "north" |
NorthNortheast | "northNortheast" |
NorthNorthwest | "northNorthwest" |
Northeast | "northeast" |
Northwest | "northwest" |
South | "south" |
SouthSoutheast | "southSoutheast" |
SouthSouthwest | "southSouthwest" |
Southeast | "southeast" |
Southwest | "southwest" |
West | "west" |
WestNorthwest | "westNorthwest" |
WestSouthwest | "westSouthwest" |
UVIndexCategory
Members | Value |
---|---|
Extreme | "extreme" |
VeryHigh | "veryHigh" |
High | "high" |
Moderate | "moderate" |
Low | "low" |