Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedrohcleal/timeapi
API for querying the temperature of any city in real time. Use the 'Time and Date' website to obtain information about the weather.
https://github.com/pedrohcleal/timeapi
api beatifulsoup beatifulsoup4 fastapi meterologia meterology python requests selenium weather-api webscraping
Last synced: 25 days ago
JSON representation
API for querying the temperature of any city in real time. Use the 'Time and Date' website to obtain information about the weather.
- Host: GitHub
- URL: https://github.com/pedrohcleal/timeapi
- Owner: pedrohcleal
- Created: 2024-08-12T01:05:47.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-24T15:55:48.000Z (2 months ago)
- Last Synced: 2024-10-11T18:22:20.771Z (25 days ago)
- Topics: api, beatifulsoup, beatifulsoup4, fastapi, meterologia, meterology, python, requests, selenium, weather-api, webscraping
- Language: Python
- Homepage: https://www.timeanddate.com/
- Size: 190 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
![In development](https://img.shields.io/badge/status-In%20development-red)
![FastAPI](https://img.shields.io/badge/FastAPI-007ACC?style=flat&logo=fastapi&logoColor=white)
![BeautifulSoup](https://img.shields.io/badge/BeautifulSoup-FFD700?style=flat&logo=python&logoColor=black)
![requests](https://img.shields.io/badge/requests-FF6F61?style=flat&logo=requests&logoColor=white)
![webdriver_manager](https://img.shields.io/badge/webdriver_manager-00B2A9?style=flat&logo=python&logoColor=white)
# Temperature APIThis is an API that retrieves the current temperature of cities around the world. The API uses the [Time and Date](https://www.timeanddate.com) 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:
```bash
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.```bash
python handler.py
```2. **Run the FastAPI Server**:
To start the API server, run the following command:```bash
uvicorn main:app --reload
```The server will be available at [http://127.0.0.1:8000](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:
```bash
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.