Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meteosapi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meteosapi - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

2

package.json
{
"name": "meteosapi",
"version": "1.0.1",
"version": "1.1.0",
"description": "nodejs wrapper over the Aemet public API",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -43,2 +43,58 @@ # METEOSAPI

### 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](http://www.ine.es/jaxi/menu.do?type=pcaxis&path=/t20/e245/codmun&file=inebase)
or from [here](https://iagolast.github.io/pselect/)
#### 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:
```javascript
{
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)

@@ -45,0 +101,0 @@ Ask for the weather forecast in a given province, the province code can be obtained from [here](http://www.ine.es/jaxi/menu.do?type=pcaxis&path=/t20/e245/codmun&file=inebase)

@@ -12,2 +12,12 @@ const rp = require('request-promise');

.then(response => Prediction(response)));
},
getSimpleForecast: function(id) {
let options = Options(id, apiKey);
return rp(options)
.then(response => rp({url: JSON.parse(response).datos, encoding: null})
.then(response => {
let prediction = Prediction(response);
delete prediction.forecast;
return prediction;
}));
}

@@ -14,0 +24,0 @@ }

@@ -15,7 +15,17 @@ const Meteosapi = require('../src/index.js');

assert.notEqual(data.today, undefined, 'Data.today should be defined');
assert.notEqual(data.tomorrow, undefined, 'Data.province should be defined');
assert.notEqual(data.next2, undefined, 'Data.province should be defined');
assert.notEqual(data.forecast, undefined, 'Data.province should be defined');
assert.notEqual(data.tomorrow, undefined, 'Data.tomorrow should be defined');
assert.notEqual(data.next2, undefined, 'Data.next2 should be defined');
assert.notEqual(data.forecast, undefined, 'Data. forecast be defined');
});
});
it('should return the simplified wheather', () => {
return meteosapi.getSimpleForecast(proviceKey).then(data => {
assert.equal(data.name, 'Pontevedra', 'Data.name should be "Pontevedra"');
assert.equal(data.province, 'Pontevedra', 'Data.province should be "Pontevedra"');
assert.notEqual(data.today, undefined, 'Data.today should be defined');
assert.notEqual(data.tomorrow, undefined, 'Data.tomorrow should be defined');
assert.notEqual(data.next2, undefined, 'Data.next2 should be defined');
assert.equal(data.forecast, undefined, 'Data.forecast should be defined');
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc