Skip to content

src/index.ts

36 lines · 1.0 KB · TypeScript
Raw
import {
	getPollen as fetchPollen,
	type GetPollenInput,
	type GetPollenResult,
	type PollenType,
	type PollenLevel,
	type PollenLevelLabel,
} from './getPollen'

export type {
	GetPollenInput,
	GetPollenResult,
	PollenType,
	PollenLevel,
	PollenLevelLabel,
}

/**
 * Fetch pollen grain levels for a city or lat/lon via Open-Meteo Air Quality API.
 * Use when you need a slim allergy/pollen pulse. Coverage is Europe-focused
 * (CAMS); outside Europe hourly pollen fields are usually null.
 *
 * @param input - `location` and/or `latitude`+`longitude`, optional `hours`
 * @returns Place, coords, time, levels per pollen type present, brief summary
 *
 * @example
 * import { getPollen } from 'kody:@reng/pollen'
 *
 * const berlin = await getPollen({ location: 'Berlin', hours: 24 })
 * // { place: { name: 'Berlin', … }, levels: { grass: { value, label }, … }, summary: '…' }
 */
export async function getPollen(input: GetPollenInput = {}): Promise<GetPollenResult> {
	return fetchPollen(input)
}

export default getPollen