This is a project on extracting weather data from the OpenWeatherMap API using Python and AWS EC2. The process involves creating an account on OpenWeatherMap and getting an API key, installing the requests library for Python, creating a Python script that makes a request to the OpenWeatherMap API, passing the API key to the request, specifying the city or location for which you want to get weather data, getting the response from the API, parsing the response to get the weather data, saving the weather data to a file, and deploying the Python script to AWS EC2.
- To get started with the OpenWeatherMap API, login to https://openweathermap.org/
- Under Your username, click
My APIs
and grab your WeatherMap API key.
Copy the key and save in your project folder.- On the Navigation Menu, click on API
- Select your preferred API. For this project, click on https://openweathermap.org/current#geocoding
- To test your API, paste the URL on a browser search bar and replace
{City}
and{API}
with any valid city name and the API key you got in step 2 above
Login to your AWS account here: https://console.aws.amazon.com/
Under Services or on the search bar, select or search for EC2
Click Launch an instance
- Provide a name for your server
- Under Application and OS images select
Ubuntu
- Under instance type, select
t2.micro
family instance- As for Key Pair (login), click on
Create new Key pair
A create key pair wizard appears
Provide a name for your key pair and clickcreate
- A
<key-pair_name.pem>
file is downloaded to your local machine.- In Network Settings under Firewall (Security Groups), you can choose to let AWS
create security group
for you or you canselect existing security group
.
Whichever method you choose make sure youallow SSH traffic from my IP
or fromAnywhere
- Click on
Launch Instance