# JavaScript Wrapper

Meteostat provides a convenient JavaScript wrapper for its JSON API.

Table of Contents

# Installation

To install the package, run:

npm install meteostat

or

yarn add meteostat

# Usage

All you need to get started is an API key, which can be generated here (opens new window). Once you have your personal API key, you can create a client:

import Meteostat from 'meteostat'

const meteostat = new Meteostat('YOUR_API_KEY_HERE')

;(async () => {
  try {
    const { data } = await meteostat.stations.search({ query: 'Sao Paulo' })
    console.log(data)
  } catch (error) {
    console.log(error)
  }
})()

# Weather Stations

The methods described in this chapter provide access to meta and weather data of actual weather stations. Alternatively, you can query data by geographical coordinates using point data.

# Finding Weather Stations

This method provides access to the data made available through the stations/search endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.stations.search({ query: 'Sao Paulo' })

# Nearby Weather Stations

This method provides access to the data made available through the stations/nearby endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.stations.nearby({
  lat: -23.5505199,
  lon: -46.6333094,
})

# Meta Data

This method provides access to the data made available through the stations/meta endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.stations.meta({
  id: '83779',
})

# Hourly Data

This method provides access to the data made available through the stations/hourly endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.stations.hourly({
  station: 83779,
  start: '2020-11-12',
  end: '2020-11-12',
})

# Daily Data

This method provides access to the data made available through the stations/daily endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.stations.daily({
  station: 83779,
  start: '2020-11-12',
  end: '2020-11-12',
})

# Climate Normals

This method provides access to the data made available through the stations/climate endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.stations.climate({
  station: 83779,
})

# Point Data

The methods described in this chapter provide access to meteorological data through geographical coordinates.

# Hourly Data

This method provides access to the data made available through the point/hourly endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.point.hourly({
  lat: -23.5505199,
  lon: -46.6333094,
  start: '2020-11-12',
  end: '2020-11-12',
})

# Daily Data

This method provides access to the data made available through the point/daily endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.point.daily({
  lat: -23.5505199,
  lon: -46.6333094,
  start: '2020-11-12',
  end: '2020-11-12',
})

# Climate Normals

This method provides access to the data made available through the point/climate endpoint. The method takes the same parameters and uses the same response format as the corresponding endpoint.

meteostat.point.climate({
  lat: -23.5505199,
  lon: -46.6333094,
})
Last Updated: 11/23/2020, 9:19:52 AM