Skip to content

m210/weather-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather Service Description

The weather service provides an API for retrieving weather data. It includes three main endpoints, each of which performs a specific function. Below you will find a description of each endpoint, along with a link to the Swagger documentation for more information.

Service Endpoints

  1. Get a list of the last 10 requested cities.
  • URL: http://localhost:8080/weather
  • Method: GET
  • Description: This endpoint lists the cities requested by the user. This is needed to retrieve information about deleting data for a city.
  1. Get weather by city
  • URL: http://localhost:8080/weather/getByCity?city=cityname
  • Method: GET
  • Parameters:
  • city (string, required) - the name of the city for which you want to retrieve weather data.
  • Description: This endpoint allows the user to retrieve current weather conditions for the specified city. The response contains detailed weather information relevant to the requested city. If an invalid city name is passed, the service may return an error message.
  1. Deleting City Data

Documentation

For more detailed information about available endpoints, their parameters, and service features, you can use the Swagger documentation user interface:

Application Modes

The application supports two modes that determine how weather data is retrieved. The available modes are listed below:

1. ON_DEMAND

  • Description: In this mode, the application retrieves weather data as needed, when data is only required upon user request, for example, when the user enters a city name. In this case, the application sends a request to the API and returns the current weather data.

2. POLLING

  • Description: In POLLING mode, the application automatically and periodically requests weather data every 10 seconds.

Requirement to launch the application with parameters

For the application to function correctly, you must specify certain parameters when launching it.

Application Launch Parameters

  1. OpenWeatherMap API Key
  • Parameter: --openweathermap.api.key
  • Description: This parameter specifies the API key that must be obtained from the OpenWeather platform. It allows the application to authenticate when sending API requests and receive up-to-date weather data. Be sure to replace the empty string with your valid API key.
  1. Service Operation Mode
  • Parameter: --openweathermap.api.mode
  • Description: This parameter determines the application's operation mode.
  1. Server Port
  • Parameter: --server.port
  • Description: This parameter sets the port on which your Spring Boot application will run. By default, Spring Boot uses port 8080, but if it is busy or you need to use a different port (for example, for deployment in a multi-application environment), you can change it to any available value. Make sure the specified port does not conflict with other services on this machine.

Example Start Command

An example command to start your application with the required parameters looks like this:

java -jar weather-api-0.0.1-SNAPSHOT.jar --openweathermap.api.key="your_api_key" --openweathermap.api.mode=POLLING --server.port=8090

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages