A REST API to get current temperature for a given a location specified as (latitude
and longitude
) pair or a zipcode
. The API relies upon externel weather services such as NOAA, Weather.com and Accuweather. aiohttp is used to build this application.
Follow these steps to setup the application
Clone and start mock-weather-api Helper Application that emulates NOAA, Weather.com and Accuweather.
git clone https://github.com/shipwell/mock-weather-api.git && \
cd mock-weather-api && \
python3 -m venv venv && \
source venv/bin/activate && \
pip3 install -r requirements.txt && \
FLASK_APP=app.py FLASK_DEBUG=1 flask run
git clone https://github.com/vamshikr/sure_weather.git && \
cd sure_weather
export FLASK_APP="http://localhost:5000"
export WEATHERDOTCOM_URL="$FLASK_APP"
export ACCUWEATHER_URL="$FLASK_APP"
export NOAA_URL="$FLASK_APP"
export GOOGLE_MAPS_APIKEY=<your google maps api key>
./run_server.sh
20-10-2019:16:32:55,679 INFO [__init__.py:12] Adding weather.com
20-10-2019:16:32:55,679 INFO [__init__.py:15] weather.com added
20-10-2019:16:32:55,679 INFO [__init__.py:12] Adding accuweather
20-10-2019:16:32:55,679 INFO [__init__.py:15] accuweather added
20-10-2019:16:32:55,679 INFO [__init__.py:12] Adding noaa
20-10-2019:16:32:55,679 INFO [__init__.py:15] noaa added
======== Running on http://127.0.0.1:8080 ========
-
The API endpoint is http://localhost:8080/current_weather
-
Only support
GET
method
Key | Value | Description |
---|---|---|
|
floating-point number between |
Required if using along with |
|
floating-point number between |
Required if using along with |
|
a positive 5-6 digit number, Example: |
Optional, use either |
|
comma separated string of service names, example: `services=accuweather,noaa' |
Optional, if not specified uses all the services |
curl -X GET --insecure --globoff 'http://localhost:8080/current_weather?latitude=33.33&longitude=44.44&services=accuweather,noaa'
{
"latitude": 30.4570672,
"longitude": -97.68194299999999,
"datetime": "2019-10-20T22:15:12",
"services": [
"weather.com",
"accuweather",
"noaa"
],
"temperature": {
"fahrenheit": 49,
"celsius": 9.44
}
}
Key | Value |
---|---|
|
Floating-point number between |
|
Floating-point number between |
|
Timestamp in UTC ISO-8601 format |
|
List of services used in getting the current weather data |
|
Current temperature in |
|
Current temperature in |