WeatherAPI-hx
An API wrapper for https://www.weatherapi.com/
About
weatherapi-hx is a Haxe library for interacting with https://www.weatherapi.com/. You can get all sorts of weather-related data in either JSON or XML format!
Installation
haxelib install weatherapi-hx
Example
import weather.api.WeatherAPI; class Main { static inline function main():Void { var wapi = new WeatherAPI("your-api-key-here"); // returns timezone data for London in JSON format. wapi.getTimeZone({query: "London"}); } }
Documentation
* All function parameters have these 2, so I'll document them here:
- query:String | "city/state/country name, IP address, etc."
(THIS PARAMETER IS ALWAYS REQUIRED!)- format:Null<Format> |
JSONorXML(JSONby default.)Now onto the others:
getAstronomy()Params: date:Null<String> (
"2010-1-1"by default.) | Date to fetch astronomy data from. Format must beyyyy-MM-dd. Date must be on or after2010-1-1.
getCurrent()Params: aqi:Null<Bool> (
falseby default.) | Get air quality data.
getForecast()Params: days:Null<Int> (
1by default.) | Number of days of weather forecast. Value ranges from1to10. | alerts:Null<Bool> (falseby default.) | Get weather alert data. | aqi:Null<Bool> (falseby default.) | Get air quality data.
* NOTE: You need to have an upgraded API plan to use this function. Yes, I agree that it's stupid. You can read more about this here.
getHistory()Params: date:Null<String> (
"2010-1-1"by default.) | Date to fetch history info from. Format must beyyyy-MM-dd. Date must be on or after2010-1-1.
getSearchOrAutoComplete()Params: Just the 2 standard ones.
getSports()Params: Just the 2 standard ones.
getTimeZone()Params: Just the 2 standard ones.