Skip to content

API for querying the temperature of any city in real time. Use the 'Time and Date' website to obtain information about the weather.

Notifications You must be signed in to change notification settings

pedrohcleal/timeAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

In development FastAPI BeautifulSoup requests webdriver_manager

Temperature API

This is an API that retrieves the current temperature of cities around the world. The API uses the Time and Date website to get weather information.

Technologies Used

  • FastAPI: Web framework for creating the API.
  • BeautifulSoup: For parsing and extracting data from HTML pages.
  • requests: For making HTTP requests.

Features

  • /all/countries: Returns a list of all available countries for queries.
  • /all/cities: Returns a list of all available cities for queries.
  • /{country}/{city}: Returns the current temperature of the specified city in the specified country.

Installation

Clone this repository and install the dependencies:

git clone https://github.com/pedrohcleal/timeAPI.git
cd timeAPI
pip install -r requirements.txt

Usage

  1. Update Cities: To update the list of available cities, run the handler.py script. This will use Selenium to collect data from Time and Date.

    python handler.py
  2. Run the FastAPI Server: To start the API server, run the following command:

    uvicorn main:app --reload

    The server will be available at http://127.0.0.1:8000.

Project Structure

  • handler.py: Contains functions for collecting and processing city and temperature data.
  • main.py: Defines the API endpoints using FastAPI.
  • crud.py: Helper functions for text sanitization and data saving.

Dependencies

Make sure to keep the requirements.txt file updated with all the necessary libraries. The requirements.txt file can be generated with:

pip freeze > requirements.txt

Contribution

If you would like to contribute to the project, feel free to submit pull requests. For issues or questions, open an issue on GitHub.

About

API for querying the temperature of any city in real time. Use the 'Time and Date' website to obtain information about the weather.

Topics

Resources

Stars

Watchers

Forks

Languages