This project provides a RESTful API to collect, store, and manage air quality data for cities in India. It uses data fetched from the OpenAQ API and stores the data in a PostgreSQL database. The application is built using Flask and SQLAlchemy, with asynchronous data fetching using aiohttp
to efficiently handle large datasets. The collected data can be accessed and queried through a web interface.
- Real-Time Data Fetching: Fetch air quality measurements (such as PM2.5, PM10, CO, NO2, etc.) from the OpenAQ API in real-time.
- Structured Data Storage: Store structured data using PostgreSQL, with relationships between cities, countries, and air quality measurements.
- Web Interface: A user-friendly interface to view the air quality data in tabular format.
- Scheduled Data Updates: Automatically fetch and update data every day at midnight using Python's
schedule
library. - Cross-Origin Resource Sharing (CORS): Ensures the application can be accessed by clients from different domains.
- Flask: Web framework for creating the API and handling HTTP requests.
- SQLAlchemy: ORM for interacting with the PostgreSQL database.
- PostgreSQL: A powerful, open-source relational database used for storing the data.
- aiohttp: Asynchronous HTTP client for making API requests.
- dotenv: To manage environment variables (e.g., API keys, database URL).
- schedule: Python library for scheduling periodic tasks.
- HTML/CSS: Frontend technologies for displaying data in a clean and responsive format.
- Python 3.7+: Ensure Python is installed on your machine.
- PostgreSQL: You need a PostgreSQL database for storing the air quality data.
- Environment Variables: Use a
.env
file to store sensitive credentials (e.g., API keys, database URLs).
Follow these steps to set up the project:
-
Clone the repository:
git clone https://github.com/Unnati-techie/AIR-QUALITY-DATA.git cd AIR-QUALITY-DATA
-
Create and activate a virtual environment:
For macOS/Linux:
python3 -m venv venv source venv/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up environment variables:
DATABASE_URL=your_postgresql_database_url
API_KEY=your_openaq_api_key