Getting Started with Air Quality CLI

Getting Started with Air Quality CLI

Air Quality CLI Tutorial


Air Quality CLI is a small CLI tool that is powered by air-quality PHP package. I launched a new open source project called Air Quality CLI, which allows you to get real-time air quality data directly from your terminal. With this tool, you can easily monitor the air quality values like grass pollen, birch pollen, dust, etc., in your area and make informed decisions about your health and well-being.

The project is built on top of my Air Quality library, which provides a simple and reliable API for accessing air quality data from OpenMeteo API. With just a few lines of code, you can retrieve pollution levels, AQI values, and other important air quality metrics.

๐Ÿš€ Installation


  • Composer installed

To install, do:

composer global require mihaichris/air-quality-cli

This command will install the command globally for the Composer and can be called anywhere from the terminal.

๐Ÿ’ก Features

Air Quality CLI encapsulates many awesome features, like:

  • Getting current air quality information for a specific location, based on coordinates;

  • Getting air quality between specific dates;

  • Getting air quality from the past days;

  • Getting forecast air quality, and also filtering based on the pollutants that you are interested in;

    And more are coming on the road!

๐Ÿ”จ Basic Usage

A simple command for getting all current pollutants from Bucharest.

air-quality.bat current latitude=44.38 longitude=26.14

This command will print something like this:

Running the above command will return a list of the number of pollutants and pollen listed on OpenMeteo website alongside their index values.

๐Ÿ“ Get air quality between two dates

This command will list the pollutants from Bucharest between two dates given as parameters.

air-quality.bat between latitude=44.38 longitude=26.14 start_date=2023-05-26 end_date=2023-05-27

Adding no filter to the command will output the values for all the pollutants.

Let's see another example for getting the pollutants between dates, but now we will give another parameter, variables which filter the pollutants by the variables you want to output.

air-quality.bat between latitude=44.38 longitude=26.14 start_date=2023-08-22 end_date=2023-08-23 variables=ozone,grass_pollen

If you don't know what variables are available, you can run the following command to get all the variables that can be passed as a filter:

air-quality.bat variables

Easy, right?

๐Ÿ“ Get air quality forecast

One of the most significant features that makes this application useful is the ability to get the future air quality from a certain location. Right now, the forecast is provided for a maximum of 5 days in the feature.

air-quality.bat next days=2 variables=grass_pollen latitude=44.38 longitude=26.14

The CLI is still in development, with more new features on the road. The initial idea of the project was for personal use, but I thought it will also be useful for others. ๐Ÿ˜€

๐Ÿค” Contribute to Air Quality CLI

If you ever encounter a bug or feel like Air Quality CLI needs one more feature, you can send your pull requests directly to the official repository: