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

api-ow-chaning

v1.1.5

Published

Api que te dice el tiempo actual de un lugar

Downloads

15

Readme

Openweathermap api librería

Build Status npm version Coverage Status Documentation

Obtiene la respuesta del tiempo actual de un lugar usando diferentes opciones de filtro.

Nota

Primero debes registrarte en openweather dede aquí OpenWeather, luego dirigirse hasta aquí API keys para crear y obtener su key, después copiar la key y pegarla en your-apiKey.

Instalación

Ejecutar este comando

npm install api-ow-chaning

Uso

Seguir estas instrucciones de uso

Poner la API key de Openweathermap

Poner tu key en el archivo test/constants.js en your-apiKey para ejecutar las pruebas.

module.exports = {
    API_KEY: 'your-apiKey',
    API_URL: 'http://api.openweathermap.org'
};

Como añadirlo

const lib = require('openweather-api-chaning');
import lib form 'openweather-api-chaning';

Para obtener el pronostico del tiempo, por defecto un día

  • Obtener el tiempo actual buscando mediante el nombre del lugar
const m = lib.ApiService;

const api = new m('your-apiKey', 'es', 'm');

api.searchByName('Barcelona', 'es')
    .then(data => console.log(data))
    .catch(error => console.log(error));
  • Obtener el tiempo actual mediante la localización
const m = lib.ApiService;

const api = new m('your-apiKey', 'es', 'm');

api.searchByGeolocationGeographic({ lat: 43.2633534, lon: -2.951074 })
    .then(data => console.log(data))
    .catch(error => console.log(error));
  • Obtener el tiempo actual mediante el código postal del lugar
const m = lib.ApiService;

const api = new m('your-apiKey', 'es', 'm');

api.searchZipPostcode('08080', 'es')
    .then(data => console.log(data))
    .catch(error => console.log(error));

// Espera una respuesta de este estilo:

{
    coord: { lon: 2.16, lat: 41.39 },
    weather: [
        {
            id: 802,
            main: 'Clouds',
            description: 'nubes dispersas',
            icon: '03d'
        }
    ],
    base: 'stations',
    main: {
        temp: 10.39,
        feels_like: 5.25,
        temp_min: 8.89,
        temp_max: 11.67,
        pressure: 999,
        humidity: 50
    },
    visibility: 10000,
    wind: { speed: 4.6, deg: 320 },
    clouds: { all: 40 },
    dt: 1607173717,
    sys: {
        type: 1,
        id: 6398,
        country: 'ES',
        sunrise: 1607151749,
        sunset: 1607185327
    },
    timezone: 3600,
    id: 3128760,
    name: 'Barcelona',
    cod: 200
}

Para obtener el pronostico del tiempo de 5 días

Puede buscar el pronóstico del tiempo durante 5 días con datos cada 3 horas por nombre de ciudad añadiendo el flag true como ultimo parámetro.

  • Obtener el tiempo actual buscando mediante el nombre del lugar
const m = lib.ApiService;

const api = new m('your-apiKey', 'es', 'm');

api.searchByName('Barcelona', 'es', true)
    .then(data => {

        const { list } = data;
        // example
        list.forEach(e => {
            console.log(e);
        });
        
    })
    .catch(error => console.log(error));
  • Obtener el tiempo actual mediante la localización
const m = lib.ApiService;

const api = new m('your-apiKey', 'es', 'm');

api.searchByGeolocationGeographic({ lat: 43.2633534, lon: -2.951074 }, true)
    .then(data => {

        const { list } = data;
        // example
        list.forEach(e => {
            console.log(e);
        });
        
    })
    .catch(error => console.log(error));
  • Obtener el tiempo actual mediante el código postal del lugar
const m = lib.ApiService;

const api = new m('your-apiKey', 'es', 'm');

api.searchZipPostcode('08080', 'es', true)
    .then(data => {

        const { list } = data;
        // example
        list.forEach(e => {
            console.log(e);
        });
        
    })
    .catch(error => console.log(error));

// Espera una respuesta de este estilo:

{
    cod: "200",
    message: 0,
    cnt: 40,
    list: [
        {
            dt: 1607256000,
            main: {
                temp: 282.82,
                feels_like: 277.43,
                temp_min: 282.82,
                temp_max: 283.91,
                pressure: 1003,
                sea_level: 1003,
                grnd_level: 996,
                humidity: 62,
                temp_kf: -1.09
            },
            weather: [
                {
                    id: 802,
                    main: "Clouds",
                    description: "scattered clouds",
                    icon: "03d"
                }
            ],
            clouds: {
                all: 31
            },
            wind: {
                speed: 5.49,
                deg: 291
            },
            visibility: 10000,
            pop: 0,
            sys: {
                pod: "d"
            },
            dt_txt: "2020-12-06 12:00:00"
        },
        {
            dt: 1607266800,
            main: {
                temp: 284.14,
                feels_like: 278.5,
                temp_min: 284.14,
                temp_max: 284.79,
                pressure: 1002,
                sea_level: 1002,
                grnd_level: 996,
                humidity: 57,
                temp_kf: -0.65
            },
            weather: [
                {
                    id: 803,
                    main: "Clouds",
                    description: "broken clouds",
                    icon: "04d"
                }
            ],
            clouds: {
                all: 64
            },
            wind: {
                speed: 5.86,
                deg: 286
            },
            visibility: 10000,
            pop: 0,
            sys: {
                pod: "d"
            },
            dt_txt: "2020-12-06 15:00:00"
        },
        {
            dt: 1607277600,
            main: {
                temp: 283.32,
                feels_like: 278.46,
                temp_min: 283.32,
                temp_max: 283.42,
                pressure: 1003,
                sea_level: 1003,
                grnd_level: 997,
                humidity: 59,
                temp_kf: -0.1
            },
            weather: [
                {
                    id: 802,
                    main: "Clouds",
                    description: "scattered clouds",
                    icon: "03n"
                }
            ],
            clouds: {
                all: 46
            },
            wind: {
                speed: 4.68,
                deg: 305
            },
            visibility: 10000,
            pop: 0,
            sys: {
                pod: "n"
            },
            dt_txt: "2020-12-06 18:00:00"
        },
        ....
        
    ],
    city: {
        id: 3128760,
            name: "Barcelona",
            coord: {
            lat: 41.3888,
            lon: 2.159
        },
        country: "ES",
        population: 1621537,
        timezone: 3600,
        sunrise: 1607238205,
        sunset: 1607271721
    }
}

Autor

El autor es Sebastián Moreno Saavedra

License

MIT