Comparing version 1.1.2 to 1.1.3
import { WeatherApiResponse } from '@openmeteo/sdk/weather-api-response'; | ||
/** | ||
* Retrieve data from the Open-Meteo weather API | ||
* | ||
* @param {string} url Server and endpoint. E.g. "https://api.open-meteo.com/v1/forecast" | ||
* @param {any} params URL parameter as an object | ||
* @param {number} [retries=3] Number of retries in case of an server error | ||
* @param {number} [backoffFactor=0.2] Exponential backoff factor to increase wait time after each retry | ||
* @param {number} [backoffMax=2] Maximum wait time between retries | ||
* @returns {Promise<WeatherApiResponse[]>} | ||
*/ | ||
declare function fetchWeatherApi(url: string, params: any, retries?: number, backoffFactor?: number, backoffMax?: number): Promise<WeatherApiResponse[]>; | ||
export { fetchWeatherApi }; |
@@ -41,2 +41,12 @@ "use strict"; | ||
} | ||
/** | ||
* Retrieve data from the Open-Meteo weather API | ||
* | ||
* @param {string} url Server and endpoint. E.g. "https://api.open-meteo.com/v1/forecast" | ||
* @param {any} params URL parameter as an object | ||
* @param {number} [retries=3] Number of retries in case of an server error | ||
* @param {number} [backoffFactor=0.2] Exponential backoff factor to increase wait time after each retry | ||
* @param {number} [backoffMax=2] Maximum wait time between retries | ||
* @returns {Promise<WeatherApiResponse[]>} | ||
*/ | ||
function fetchWeatherApi(url, params, retries = 3, backoffFactor = 0.2, backoffMax = 2) { | ||
@@ -43,0 +53,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "openmeteo", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Open-Meteo Weather API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -10,12 +10,12 @@ # Open-Meteo API Typescript SDK | ||
This ia an API client to get weather data from the [Open-Meteo Weather API](https://open-meteo.com) in Typescript / Javascript. | ||
This is a TypeScript/Javascript API client designed for retrieving weather information from the [Open-Meteo Weather API](https://open-meteo.com) in Typescript / Javascript. | ||
Instead of using JSON, the API client uses FlatBuffers to transfer data. Encoding data in FlatBuffers is more efficient for long time-series data. The schema definition files can be found on [GitHub open-meteo/sdk](https://github.com/open-meteo/sdk). | ||
Unlike conventional JSON APIs, this API client employs FlatBuffers for data transfer. This is a more efficient method, particularly for handling extended time-series data. You can locate the schema definition files on [GitHub open-meteo/sdk](https://github.com/open-meteo/sdk). | ||
Features: | ||
- Simple access to weather data | ||
- Get weather data for multiple locations in one call | ||
- Automatic retry on error | ||
- Reduced bandwidth and fast parsing using FlatBuffers and Zero Copy | ||
- Type annotated | ||
- Easily access weather data | ||
- Retrieve weather data for multiple locations with a single request | ||
- Automatic retry mechanism for handling errors | ||
- Enhanced bandwidth efficiency and speedy parsing using FlatBuffers and Zero Copy technology | ||
- Type annotations for enhanced code clarity | ||
@@ -30,2 +30,4 @@ ## Install | ||
Note: The Open-Meteo [API documentation](https://open-meteo.com/en/docs) generates the required Typescript code automatically. | ||
```ts | ||
@@ -44,4 +46,4 @@ import { fetchWeatherApi } from 'openmeteo'; | ||
// Helper function to form time range | ||
export const range = (start: number, stop: number, step: number) => | ||
// Helper function to form time ranges | ||
const range = (start: number, stop: number, step: number) => | ||
Array.from({ length: (stop - start) / step }, (_, i) => start + i * step); | ||
@@ -90,8 +92,37 @@ | ||
// `weatherData` now contains a simple structure with arrays for datetime and weather data | ||
for (let i = 0; i < daily.time.length; i++) { | ||
console.log(daily.time[i].toISOString(), daily.weatherCode[i], daily.temperatureMax[i], daily.temperatureMin[i]); | ||
for (let i = 0; i < weatherData.daily.time.length; i++) { | ||
console.log( | ||
weatherData.daily.time[i].toISOString(), | ||
weatherData.daily.weatherCode[i], | ||
weatherData.daily.temperatureMax[i], | ||
weatherData.daily.temperatureMin[i] | ||
); | ||
} | ||
``` | ||
## Parameter | ||
This package only exposes one function to fetch weather data and decode the FlatBuffer messages. | ||
```ts | ||
/** | ||
* Retrieve data from the Open-Meteo weather API | ||
* | ||
* @param {string} url Server and endpoint. E.g. "https://api.open-meteo.com/v1/forecast" | ||
* @param {any} params URL parameter as an object | ||
* @param {number} [retries=3] Number of retries in case of an server error | ||
* @param {number} [backoffFactor=0.2] Exponential backoff factor to increase wait time after each retry | ||
* @param {number} [backoffMax=2] Maximum wait time between retries | ||
* @returns {Promise<WeatherApiResponse[]>} | ||
*/ | ||
async function fetchWeatherApi( | ||
url: string, | ||
params: any, | ||
retries = 3, | ||
backoffFactor = 0.2, | ||
backoffMax = 2 | ||
): Promise<WeatherApiResponse[]> { | ||
} | ||
``` | ||
[build-img]:https://github.com/open-meteo/typescript/actions/workflows/release.yml/badge.svg | ||
@@ -98,0 +129,0 @@ [build-url]:https://github.com/open-meteo/typescript/actions/workflows/release.yml |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13526
81
136