Getting current and forecast weather data is possible via the standard web connector and the Apixu restful API (https://www.apixu.com/api.aspx).
STEP 1: CREATE A FREE ACCOUNT IN APIXU
Sign up for a free account to receive an API key. Free accounts may make up to 10,000 calls per month. https://www.apixu.com/signup.aspx
STEP 2: ADD A WEB CONNECT DATASTREAM IN DATATAP
- Datastreams -> Add -> Web Connect
- Name: Add a datastream name
- Connection: leave this blank
- URL: https://api.apixu.com/v1/{report type}.json?key={API key}&q={request parameter}
- Request method: GET
- Date format: %Y-%m-%d
- Parser: JSON
- Encoding: UTF-8
- Data key: for forecast report, paste "forecast.forecastday"
- Column mapping: for historical report, paste the following:
{
"totalprecip_mm": "forecast.forecastday[0].day.totalprecip_mm",
"avgtemp_c": "forecast.forecastday[0].day.avgtemp_c",
"maxtemp_c": "forecast.forecastday[0].day.maxtemp_c",
"mintemp_c": "forecast.forecastday[0].day.mintemp_c",
"date": "forecast.forecastday[0].date",
"maxwind_kph": "forecast.forecastday[0].day.maxwind_kph",
"condition": "forecast.forecastday[0].day.condition.text"
}
STEP 3: ADJUST YOUR REQUEST URL
Element 1: Report Type
Depending on the report type, date and details you want to get from Apixu, your URL will change:
Current -> https://api.apixu.com/v1/current.json?
Forecast -> https://api.apixu.com/v1/forecast.json?
Search or Autocomplete -> https://api.apixu.com/v1/search.json?
History -> https://api.apixu.com/v1/history.json?
Element 2: API Key
Insert your API key: https://api.apixu.com/v1/history.json?key=abcd123456
Element 3: Request Parameter
Examples from Apixu:
- Latitude and Longitude (Decimal degree) e.g: q=48.8567,2.3508
- city name e.g.: q=Paris
- US zip e.g.: q=10001
- UK postcode e.g: q=SW1
- Canada postal code e.g: q=G2J
- metar:<metar code> e.g: q=metar:EGLL
- iata:<3 digit airport code> e.g: q=iata:DXB
- auto:ip IP lookup e.g: q=auto:ip
- IP address (IPv4 and IPv6 supported) e.g: q=100.0.0.1
Read more about the different request parameters and optional elements here: https://www.apixu.com/doc/request.aspx
Examples:
To get historical weather from Paris from a specific date onward, the URL would be:
https://api.apixu.com/v1/history.json?key=abcd123456&q=Paris&dt={start}
To get forecast data for the next 5 days from Paris the URL would be:
https://api.apixu.com/v1/forecast.json?key=abcd123456&q=Paris&days=5
Comments
0 comments
Article is closed for comments.