Inspiration
I wanted to work on something practical, something that involves real-world data instead of just static inputs. Weather influences everybody’s daily choices. So, I thought, how about creating a program that retrieves real-time weather information? This project gave me the opportunity to learn how APIs link applications to real-time information that is useful and continuously updated.
What it does
The project is about the back-end programming and working of a weather forecasting app that enables user to get current weather information for any city by using the OpenWeatherMap API.
How we built it
It starts by asking the user to input a city name. Since city names can include spaces, the program converts them into a format suitable for URLs by replacing spaces with "%20" to make sure the APIrequest works correctly. The user's input, along with an API key, is used to build a URL for retrieving weather data. Using the cURL library, the program sends an HTTP request to the OpenWeatherMap service. The server's response, which includes weather details in JSON format, is stored in a buffer. The jsoncpp library is used to parse this response, extracting essential weather information like the city name, temperature, humidity, weather description, and wind speed. It also checks for any rain or snow data, displaying relevant values if they are available. The program has built-in error handling to deal with problems, such as failed HTTP requests or issues with JSON parsing, providing users with error message if something goes wrong. This project uses of cURL for HTTP communication and getting data from OpenWeatherMap using API and jsoncpp for processing responses from API, storing those responses in a buffer and outputting the weather data to the user, serving as a practical example of integrating external APIs within a C++ application for real-life scenarios to get weather data from the Weather App for any city across the globe.
Challenges we ran into
The installation and the configuration of the two libraries jsoncpp and Curl was a hectic task to deal with. Also handling the spaces between the city name was quite confusing.
Accomplishments that we're proud of
The project serves as a practical example of developing dependable, user-friendly applications that incorporate real-world data, showcasing the impact of APIs on improving software functionality.
What we learned
This project helped me gain knowledge about different libraries like jsoncpp and Curl about how they work and their functions. It also helped me gain knowlege about different APIs and their usage.
What's next for Weather Forecasting System
Next, I would like to work on the front end of this program and create a user friendly interface so that people can use this forecasting system to get real time authentic weather data without any errors.
Log in or sign up for Devpost to join the conversation.