# Weather Methods Access weather data including current conditions, daily forecasts, and hourly forecasts for any location worldwide. # Weather Methods Access weather data for any location worldwide. ## Overview The Weather Methods provide access to current weather conditions and forecast data through the TelemetryOS API. Applications can query weather by city name, postal code, or geographic coordinates, with support for imperial and metric units and localized responses. ## Importing ```typescript import { weather } from '@telemetryos/sdk'; ``` ## Methods ### getConditions() Retrieve current weather conditions for a specified location. **Signature:** ```typescript async getConditions(params: WeatherRequestParams): Promise ``` **Parameters:** * `params` - Weather request parameters **WeatherRequestParams:** ```typescript type WeatherRequestParams = { city?: string; // City name (e.g., "New York" or "London, UK") postalCode?: string; // Postal/ZIP code (alternative to city) lat?: string; // Latitude (if city not provided) lon?: string; // Longitude (if city not provided) units?: 'imperial' | 'metric'; // Units system (default: imperial) language?: string; // Language code for localized responses } ``` **Returns:** `Promise` - Current weather conditions **Example:** ```typescript const conditions = await weather().getConditions({ city: 'New York', units: 'imperial' }); ``` ### getDailyForecast() Retrieve daily weather forecast for a specified location. **Signature:** ```typescript async getDailyForecast(params: DailyForecastParams): Promise ``` **Parameters:** * `params` - Forecast request parameters **DailyForecastParams:** ```typescript type DailyForecastParams = WeatherRequestParams & { days?: number; // Number of days to forecast (default: 5) } ``` **Returns:** `Promise` - Array of daily forecast data **Example:** ```typescript const forecast = await weather().getDailyForecast({ city: 'London', units: 'metric', days: 5 }); ``` ### getHourlyForecast() Retrieve hourly weather forecast for a specified location. **Signature:** ```typescript async getHourlyForecast(params: HourlyForecastParams): Promise ``` **Parameters:** * `params` - Forecast request parameters **HourlyForecastParams:** ```typescript type HourlyForecastParams = WeatherRequestParams & { hours?: number; // Number of hours to forecast (default: 24) } ``` **Returns:** `Promise` - Array of hourly forecast data **Example:** ```typescript const forecast = await weather().getHourlyForecast({ city: 'Tokyo', units: 'metric', hours: 24 }); ``` ## Types ### WeatherConditions ```typescript type WeatherConditions = { CityLocalized: string; // City name (localized) CityEnglish: string; // City name (English) WindAbbr: string; // Wind abbreviation CountryCode: string; // ISO country code Timezone: string; // Timezone WeatherText: string; // Weather description text State: string; // State/Province Pod: string; // Part of day (day/night indicator) WeatherCode: string; // Weather code (internal mapping) WindDirectionDegrees: string; // Wind direction in degrees WindDirectionEnglish: string; // Wind direction (cardinal, English) WindDirectionLocalized: string; // Wind direction (localized) RelativeHumidity: number; // Relative humidity percentage Timestamp: number; // Unix timestamp Longitude: number; // Longitude Latitude: number; // Latitude Temp: number; // Current temperature Pressure: number; // Atmospheric pressure WindSpeed: number; // Wind speed Visibility: number; // Visibility distance Precip: number; // Precipitation amount } ``` ### WeatherForecast ```typescript type WeatherForecast = { Datetime: string; // ISO datetime string Pod: string; // Part of day (day/night indicator) Label: string; // Weather description label WeatherCode: string; // Weather code Timestamp: number; // Unix timestamp Temp: number; // Temperature MinTemp: number; // Minimum temperature MaxTemp: number; // Maximum temperature } ``` ## Next Steps * **[Storage Methods](./storage-methods.md)** - Cache weather data for offline access * **[Media Methods](./media-methods.md)** - Display weather-appropriate content * **[Code Examples](../development/code-examples.md)** - Complete weather application example