UNPKG

owm-onecall-api

Version:
41 lines (40 loc) 1.69 kB
import { AxiosRequestConfig } from "axios"; import { RequestParams, ForecastRequest, Forecast, TimeMachineRequest } from "./types"; /** * Base url for the OpenWeatherMap API. * * See {@link https://openweathermap.org/api/one-call-api One Call API} for more info. * * @internal */ export declare const API_BASE = "https://api.openweathermap.org/data/3.0/onecall"; /** * API url for a Time Machine request from the OpenWeatherMap API. * * @internal */ export declare const API_TIME_MACHINE: string; /** * Basic client definintion for interacting with the OpenWeatherMap OneCall API. */ export interface OpenWeatherMapClient { /** * Make a Forecast request. * * See {@link https://openweathermap.org/api/one-call-api One Call API} for more info. * @param request Required Forecast request parameters. * @param optionalParams Optional query params to add to the request. */ forecast: <R extends Forecast>(request: ForecastRequest, optionalParams?: RequestParams) => Promise<R>; timeMachine: <R extends Forecast>(request: TimeMachineRequest, optionalParams?: RequestParams) => Promise<R>; } /** * Default implementation of ClientFactory for making authorized requests to the OpenWeatherMap API. * * Note: Get your token from {@link https://openweathermap.org/full-price#current OpenWeatherMap}. * * @param apiToken Developer API token. * @param requestConfig Optional config to change the way axios makes the request. * @returns Client for interacting with the API. */ export declare function openWeatherMapClient(apiToken: string, requestConfig?: AxiosRequestConfig): OpenWeatherMapClient;