Skip to content

Taengsil/University-Project---WeatherAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Description

A project I have worked on for an interview at GBET, then used as my master's thesis in University, and my first project that had unit tests.

Interview Project Requirements

Using the OpenWeatherMap API at http://openweathermap.org/current, create a program that prompts for a city name and returns the current temperature for the city.

Example Output Where are you? Chicago IL Chicago weather: 65 degrees Fahrenheit

Constraint

  • Keep the processing of the weather feed separate from the part of your program that displays the results.

Challenges

  • The API gives the sunrise and sunset times, as well as the humidity and a description of the weather. Display that data in a meaningful way.
  • The API gives the wind direction in degrees. Convert it to words such as “North,” “West,” “South,” “Southwest,” or even “South-southwest.”
  • Develop a scheme that lets the weather program tell you what kind of day it is. If it’s 70 degrees and clear skies, say that it’s a nice day out!
  • Display the temperature in both Celsius and Fahrenheit.
  • Based on the information, determine if the person needs a coat or an umbrella.

Use .NET 5, C#, Visual Studio 2019 Community Edition

Can use either ConsoleApp or ASP.NET WebApi

https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-5.0

Installation:

Download the solution from GitHub

Adding appsettings.json

In the WeatherAPI folder, create a file called appsettings.json with the following text:


{
  "OpenWeatherAPIRequest": {
    "isEnabled": false,
    "weatherAPIUrl": "http://api.openweathermap.org/data/2.5/weather?q=",
    "options": "&units=imperial&appid=",
    "apiKey": ""
  }
}

Optional - Fill in the blank api key with your OpenWeatherMap API Key

Create an account for the free version of OpenWeatherMap and fill in the blank API key with your own api key, so the field looks like the following:

"isEnabled": true,
[...]
"apikey": "yourapikey123"

Project Runtime Explanation

In the appsettings.json, the values weatherAPIUrl, options and apiKey are combined together to form a link. An example link would be http://api.openweathermap.org/data/2.5/weather?q=&units=imperial&appid=apikey123 format, with "apikey123" being replaced by a proper api key. If the setting "isEnabled" is set to false, the app will use a default location and weather, and then process the settings based on that.

(More to be added)

About

Console App using C# / .Net that uses an api key and options to build and call a link, and then process data from the result.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages