Skip to content

abin-m/Weather-api-imd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A REST API to Get Weather Details from IMD

This API allows you to retrieve weather details from the India Meteorological Department (IMD) website by providing a city ID.

Disclaimer: All credit belongs to the India Meteorological Department. Please note that the API may not work if the website's code is changed, as it relies on web scraping.

Installation

  1. Clone the repository:

    git clone <repository_url>
  2. Navigate to the project directory:

    cd <project_directory>
    
  3. Create and activate a virtual environment:

    python3 -m venv venv
    source venv/bin/activate
  4. Install the required dependencies:

    pip install -r requirements.txt
    

Usage

  1. Run the FastAPI server:

    uvicorn main-app:app --reload
  2. Open your web browser and visit the following URL:

    http://localhost:8000/weather/{id}
  3. Replace {id} in the URL with the desired city ID.

  4. The API will return the weather details for the specified city as a JSON response.

API Documentation

GET /weather/{id} Returns the weather details for the specified city.

Parameters:

id (integer): The city ID. Example Request:

`GET /weather/90060`

Example Response:

{
  "Maximum Temp": "33.5",
  "Departure from Normal": "2",
  "Minimum Temp": "26.4",
  "24 Hours Rainfall": "NIL",
  "Relative Humidity at 0830 hrs": "82",
  "Relative Humidity at 1730 hrs": "82",
  "Todays Sunset": "18:52",
  "Tomorrow's Sunrise": "06:05",
  "Moonset": "20:53",
  "Moonrise": "07:42"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages