A node.js client library for Forecast.io API.
For explanation and more detailed info about endpoints and response format see Forecast.IO API documentation
npm install forecastio
Say you need a forecast for London, UK:
var ForecastIo = ;var forecastIo = '<apiKey>';forecastIo;
"Time Machine" Requests
Forecast.io also supports Time Machine requests. Quoting official documentation you can make request for "60 years in the past to 10 years in the future" for "many places". Example:
// What was the weather like in London on January 1st 2008?forecastIo;
#timeMachine() methods support passing additional options.
Below are some examples, for all options consult Options section of Forecast.IO API documentation.
Example of requesting ad forecast in Si(metric) units with only 'daily' fields:
var options =units: 'si'exclude: 'currently,hourly,flags';forecastIo;
Another example, a "Time Machine" request in UK units and localized in Italian:
var options =units: 'uk'lang: 'it';forecastIo;
To set timeout for requests pass a timeout option to constructor, example:
var forecastIo = '<apiKey>' timeout: 30*1000;
As a result all API request made with with this
forecastIo instance will have a timeout of 30 seconds.
Timeout option accepts time in milliseconds. If request will not finish in time - a callback will be fired with a timeout error.
- Logging (for debugging at least)
- Smarter API methods (accept
#timeMachine()and convert it to string, for example)
Fork the repo & commit changes
Make sure tests are not failing:
$ env FORECASTIO_API_KEY=
Create a pull request
- Fixed deprecation warnings.
- Promises (For compatibility callbacks are still supported).
- More informative error messages.