Skip to content

bkmandge/weather-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌦️ Weather API - Django REST Framework

This is a backend Weather API built using Django and Django REST Framework. It allows you to:

  • Add and list cities 🌍
  • Log weather data for cities 🌑️
  • Let users save favorite cities ⭐
  • Retrieve saved cities and search cities πŸ”

The project uses clean, modular design with proper serializers, views, and admin setup.


πŸš€ Features

  • βœ… City CRUD: Add and list cities with name, country, and description
  • βœ… Weather Logging: Log weather with temperature, humidity, and timestamp
  • βœ… Saved Cities: Authenticated users can save cities
  • βœ… Admin Support: All models visible and searchable in Django admin
  • βœ… Search Support: City search by name (partial match)
  • βœ… Formatted timestamps and readable outputs
  • βœ… Modular code using class-based generic views

🧱 Tech Stack

Layer Technology
Language Python
Framework Django, Django REST Framework
Database SQLite (dev), PostgreSQL-ready
Auth Django User Model
Dev Tools Postman, Git, VS Code

πŸ“ API Endpoints

Method Endpoint Description
POST /api/city-add/ Add a new city
GET /api/cities/ List all cities
GET /api/search-city/?name=udg Search cities by name (partial)
POST /api/weather-add/ Add weather data to a city
GET /api/weathers/ List all weather entries
POST /api/saved-city-add/ Save a city for a user
GET /api/saved-cities/ List saved cities
GET /api/users/ List users

πŸ§ͺ Testing API

Use Postman or cURL to test the endpoints.
Sample request to add a city:

POST /api/city-add/
{
  "name": "Pune",
  "country": "IN",
  "description": "Cultural City"
}

βš™οΈ Setup Instructions

git clone https://github.com/your-username/weather-api.git
cd weather-api

# Create and activate virtual environment
python -m venv venv
source venv\Scripts\activate  # Windows

# Install requirements
pip install -r requirements.txt

# Run migrations
python manage.py migrate

# Create superuser (for admin panel)
python manage.py createsuperuser

# Run the server
python manage.py runserver

Visit: http://127.0.0.1:8000/admin for the admin panel.


πŸ™‹β€β™€οΈ About Me

I’m a backend developer focusing on Python/Django API development, building real-world backend projects like this to demonstrate skills and help businesses connect data with users efficiently.

Reach out for collaborations, freelancing, or feedback!


πŸ“Œ To Do Next

  • πŸ” Add JWT authentication
  • 🌍 Integrate with OpenWeatherMap live API
  • πŸ“¦ Dockerize the project
  • πŸ“ˆ Add Swagger/OpenAPI documentation

πŸ“„ License

This project is for educational and portfolio use.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages