Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/indiependente/weatherlike
Node.js weather server JSON API
https://github.com/indiependente/weatherlike
Last synced: 5 days ago
JSON representation
Node.js weather server JSON API
- Host: GitHub
- URL: https://github.com/indiependente/weatherlike
- Owner: indiependente
- License: mit
- Created: 2014-06-28T20:42:07.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-08T09:38:47.000Z (over 10 years ago)
- Last Synced: 2024-11-08T15:54:28.297Z (about 2 months ago)
- Language: JavaScript
- Size: 289 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
weatherlike
===========Node.js weather server JSON API
##How it works
- Get the city woeid code from Yahoo Geo Places apis
- Query Yahoo Weather APIs for that woeid
- Reply with the JSON weather forecast for 5 days from the moment of the request##API
####weatherlike has two APIs
- ```weatherlike.inCity(city, callback)``` where you can specify the city you want the forecast for.- ```weatherlike.inWoeid(woeid, callback)``` where you can ask for that woeid in case you already know it.
##Example
More examples in `examples/`
```javascript
var weatherlike = require('./weatherlike');http.createServer(function(req, res){
if (req.method === "GET"){
var parsedURL = url.parse(req.url, true);
if (parsedURL.pathname.match("^/weatherapi/city")){
weatherlike.inCity(parsedURL.query.city, sendWeather);
}
else if (parsedURL.pathname.match("^/weatherapi/woeid")){
weatherlike.inWoeid(parsedURL.query.woeid, sendWeather);
}
}
}).listen(PORT);
```##JSON reply
####weatherlike sends back a reply like this for both requests:
```json
{"woeid":"721943","forecast":[{"code":"32","date":"4 Aug 2014","day":"Mon","high":"85","low":"68","text":"Sunny"},{"code":"32","date":"5 Aug 2014","day":"Tue","high":"87","low":"68","text":"Sunny"},{"code":"32","date":"6 Aug 2014","day":"Wed","high":"89","low":"68","text":"Sunny"},{"code":"34","date":"7 Aug 2014","day":"Thu","high":"87","low":"68","text":"Mostly Sunny"},{"code":"32","date":"8 Aug 2014","day":"Fri","high":"87","low":"69","text":"Sunny"}]}
```
As you can see you can get the woeid as soon as you get the first reply.##License
####MIT