npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meteosapi

v1.1.0

Published

nodejs wrapper over the Aemet public API

Downloads

21

Readme

METEOSAPI

nodejs wrapper over the Aemet public API

Getting started

Install dependences

yarn install

Get an API key

Go to the Aemet OpenData Website and follow the instructions to get an API key.

Crate a .env file

Since the Aemet doesn´t provide a valid ssl cerfificate nodejs will reject all the requests, to prevent this use NODE_TLS_REJECT_UNAUTHORIZED=0. The env file also will set the api-key used in the unit tests.

NODE_TLS_REJECT_UNAUTHORIZED=0
METEOSAPI_KEY="<your-api-key>"

run the tests

yarn run test

## Usage Meteosapi only provides one module with a single function getForecast(id)

Initializacion

// Require the module
const Meteosapi = require('meteosapi');
// Initialize the module with your api key.
let meteosapi = Meteosapi(key); 
// Execute a sample request for a given province
let proviceKey = 36038;
meteosapi.getForecast(proviceKey).then(console.log);

getSimpleForecast(provinceId)

Ask for the simplified weather forecast in a given province for the next 3 days. The province code can be obtained from here or from here

Example Response

getSimpleForecast returns a data object with the following fields:

  • name: Name of the municipe of the predicion
  • province: Names of the required province.
  • today: Simplified forecast for the current day
  • tomorrow: Simplified forecast for the next today
  • next2: Simplified forecast for the day after tomorrow

A simplified forecast has the following fields:

  • value: The wheater forecast value.
  • description: User readable weather forecast description.
  • tmp: The temperature values for the day
    • min: The expected min temperature
    • max: The expected max temperature

Example response:

{
    name: 'Pontevedra',
    province: 'Pontevedra',
    today: {
        value: '13',
        descripcion: 'Intervalos nubosos',
        tmp: {
            min: 6,
            max: 13
        }
    },
    tomorrow: {
        value: '13',
        descripcion: 'Intervalos nubosos',
        tmp: {
            min: 5,
            max: 16
        }
    },
    next2: {
        value: '25',
        descripcion: 'Muy nuboso con lluvia',
        tmp: {
            min: 7,
            max: 13
        }
    },
}

getForecast(provinceId)

Ask for the weather forecast in a given province, the province code can be obtained from here or from here

Example Response

getForecast returns a data object with the following fields:

  • name: Name of the municipe of the predicion
  • province: Names of the required province.
  • today: Simplified forecast for the current day
  • tomorrow: Simplified forecast for the next today
  • next2: Simplified forecast for the day after tomorrow
  • forecast: array with the raw forecast values from the Aemet API

A simplified forecast has the following fields:

  • value: The wheater forecast value.
  • description: User readable weather forecast description.
  • tmp: The temperature values for the day
    • min: The expected min temperature
    • max: The expected max temperature

Example response:

{
    name: 'Pontevedra',
    province: 'Pontevedra',
    today: {
        value: '13',
        descripcion: 'Intervalos nubosos',
        tmp: {
            min: 6,
            max: 13
        }
    },
    tomorrow: {
        value: '13',
        descripcion: 'Intervalos nubosos',
        tmp: {
            min: 5,
            max: 16
        }
    },
    next2: {
        value: '25',
        descripcion: 'Muy nuboso con lluvia',
        tmp: {
            min: 7,
            max: 13
        }
    },
    forecast: [forecastArray]
}

List of meteo values and the meanings

The value field in the simplified forecast can be one of the following, the n after the code comes from night.

11 – Despejado
11n – Despejado noche 12 Poco nuboso
12n – Poco nuboso noche
13 – Intervalos nubosos
13n – Intervalos nubosos noche
14 – Nuboso
14n – Nuboso noche
15 – Muy nuboso
16n – Muy nuboso
16 – Cubierto
16n – Cubierto
17 – Nubes altas
17n – Nubes altas noche
23 – Intervalos nubosos con lluvia
23n – Intervalos nubosos con lluvia noche
24 – Nuboso con lluvia
24n – Nuboso con lluvia noche
25 – Muy nuboso con lluvia
25n – Muy nuboso con lluvia
26 – Cubierto con lluvia
26n – Cubierto con lluvia
33 – Intervalos nubosos con nieve
33n – Intervalos nubosos con nieve noche
34 – Nuboso con nieve
34n – Nuboso con nieve noche
35 – Muy nuboso con nieve
35n – Muy nuboso con nieve
36 – Cubierto con nieve
36n – Cubierto con nieve
43 – Intervalos nubosos con lluvia escasa
43n – Intervalos nubosos con lluvia escasa noche
44 – Nuboso con lluvia escasa
44n – Nuboso con lluvia escasa noche
45n – Muy nuboso con lluvia escasa
46n – Cubierto con lluvia escasa
51 – Intervalos nubosos con tormenta
51n – Intervalos nubosos con tormenta noche
52 – Nuboso con tormenta
52n – Nuboso con tormenta noche
53 – Muy nuboso con tormenta
53n – Muy nuboso con tormenta
54 – Cubierto con tormenta
54n – Cubierto con tormenta
61 – Intervalos nubosos con tormenta y lluvia escasa
61n – Intervalos nubosos con tormenta y lluvia escasa noche 
62 Nuboso con tormenta y lluvia escasa
62n – Nuboso con tormenta y lluvia escasa noche
63 – Muy nuboso con tormenta y lluvia escasa
63n – Muy nuboso con tormenta y lluvia escasa 
64 Cubierto con tormenta y lluvia escasa 
64n Cubierto con tormenta y lluvia escasa
71 – Intervalos nubosos con nieve escasa
71n – Intervalos nubosos con nieve escasa noche 
72 Nuboso con nieve escasa
72n – Nuboso con nieve escasa noche
73 – Muy nuboso con nieve escasa
73n – Muy nuboso con nieve escasa 
74 Cubierto con nieve escasa
74n Cubierto con nieve escasa