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.
- FastAPI: Web framework for creating the API.
- BeautifulSoup: For parsing and extracting data from HTML pages.
- requests: For making HTTP requests.
- /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.
Clone this repository and install the dependencies:
git clone https://github.com/pedrohcleal/timeAPI.git
cd timeAPI
pip install -r requirements.txt
-
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
-
Run the FastAPI Server: To start the API server, run the following command:
cd app fastapi dev main.py
The server will be available at http://127.0.0.1:8000.
- 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.
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
If you would like to contribute to the project, feel free to submit pull requests. For issues or questions, open an issue on GitHub.