This repository provides access to the Open Weather API and to the Google Maps Geocoding API. In tandem, these APIs make it possible to provide location specific weather data from Open Weather based on latitude and longitude coordinates derived from an address string provided to Google Maps Geocode by the user.
You must have API keys for both Open Weather and Google Maps.
The keys are accessed via environment variables. You can set up a .env.local file in the root and set keys like this:
OPEN_WEATHER_KEY=YOUR_KEY_HERE
GAPI_KEY=YOUR_KEY_HERE
You can also pass in a value to set the Access-Control-Allow-Origin header by setting a key: ALLOW_ORIGIN=https://my-allowed-origin
All responses contain cod
, the response status code, and message
explaining the code. All other keys are spread from the upstream response.
{
cod: <status_code>,
message: <status_message>,
...<open_weather_response_json>|...<google_api_response_json>
}
lat=[float]&lon=[float] id=[string] Either an id or latitude and longitude are required and the only parameters supported at this time.
View the Open Weather documentation
Support for language parameter should be added in the future.
lat=[float]&lon=[float] id=[string] Either an id or latitude and longitude are required and the only parameters supported at this time. This returns an 8 day daily forecast.
View the Open Weather documentation
Support for language parameter should be added in the future. Currently the forecast for 8 days is returned by default and no parameter to extend to the total possible 16 days exists. Probably this should be added.
This also returns a localDt in addition to the dt. This is to provide support for local timezone information and is obtained by submitting the first dt from the Google Maps Time Zone API. Of course, if during the forecast period daylight savings time becomes in or out of effect some of the times will be 1 hour off. But this is preferable to making multiple requests to the Time Zone API for an edge case that only occurs twice a year (and only in some localities) and that ultimately is of little significance to users.
lat=[float]&lon=[float] id=[string] Either an id or latitude and longitude are required and the only parameters supported at this time. This returns an 12 forecasts spaced out by 3 hours.
View the Open Weather documentation
Support for language parameter should be added in the future. Currently the forecast for 36 hours is returned by default and no parameter to extend to the total possible 5 days exists. Probably this should be added.
lat=[float]&lon=[float] Latitude and longitude are required and the only parameters supported at this time.
View the Google Maps documentation
address=[string] A query address string to find the latitude and longitude of.
View the Google Maps documentation