py-aqi-in-api
Python SDK for the AQI.in Air Quality API.
Fully typed, async, using modern Python (3.11+), dataclasses, and httpx.
Source: This is a Python port of the aqi-in-api TypeScript SDK by @neo773.
Installation
pip install py-aqi-in-api
Requires Python 3.11+.
Usage
import asyncio
from aqi_in_api import AQIClient
async def main() -> None:
client = AQIClient()
ip_details = await client.get_ip_details()
print(f"Location: {ip_details.city}, {ip_details.country}")
nearest = await client.get_nearest_location(
lat=ip_details.lat, long=ip_details.lon,
)
station = nearest[0]
print(f"Nearest station: {station.station} ({station.location_slug})")
location = await client.get_location_by_slug(slug=station.location_slug)
print(f"Location AQI: {location[0].iaqi}")
history = await client.get_last_24_hour_history(
slug=station.location_slug, sensorname="pm25", slug_type="locationId",
)
print(f"24h PM2.5 avg: {history.avgValue}")
await client.close()
asyncio.run(main())
API
create_aqi_client(config?)
| Option | Type | Required | Description |
|---|---|---|---|
token |
str | None |
No | JWT authentication token (auto-generated if omitted) |
base_url |
str |
No | API base URL (default: https://apiserver.aqi.in) |
user_agent |
str |
No | Custom user agent |
Methods
All methods take keyword-only arguments. No *Params objects needed.
| Method | Keyword Args | Returns | Description |
|---|---|---|---|
get_ip_details() |
— | IPDetails |
Get location from your IP address |
get_nearest_location(**kwargs) |
lat, long, type? |
list[Station] |
Get nearest monitoring stations by coordinates |
get_location_by_slug(**kwargs) |
slug, type? |
list[LocationDetails] |
Get location details by slug |
search(**kwargs) |
search_string |
SearchResults |
Search locations by name |
get_last_12_hour_history(**kwargs) |
slug, sensorname, slug_type |
HistoryData |
Get 12-hour sensor history |
get_last_24_hour_history(**kwargs) |
slug, sensorname, slug_type |
HistoryDataWithWHO |
Get 24-hour history with WHO guidelines |
get_last_7_days_history(**kwargs) |
slug, sensorname, slug_type |
HistoryDataWithWHO |
Get 7-day sensor history |
get_last_30_days_history(**kwargs) |
slug, sensorname, slug_type |
HistoryDataWithWHO |
Get 30-day sensor history |
get_rankings(**kwargs) |
sensorname, type, limit=10 |
list[RankingEntry] |
Get city or country pollution rankings |
close() |
— | None |
Close the underlying HTTP client |
Types
from aqi_in_api.models import (
Station, City, State, Country,
LocationDetails, IPDetails, SearchResults, RankingEntry,
HistoryData, HistoryDataWithWHO,
IAQI, Weather, WeatherCondition, WeatherSimple, UVCondition,
SensorName, SearchType, SlugType, LocationType, RankType,
)
Development
git clone https://github.com/GuyKh/py-aqi-in-api
cd py-aqi-in-api
uv sync --dev
uv run pytest
uv run ruff check .
License
MIT
Disclaimer
This is an unofficial API client and is not affiliated with, endorsed by, or associated with AQI.in or its parent organization. This package is provided for educational and informational purposes under fair use.
Metadata
Release files for aqi-in-api 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aqi_in_api-0.0.2.tar.gz | 17.5 kB | Without provenance | Details for aqi_in_api-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aqi_in_api-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for aqi_in_api-0.0.2-py3-none-any.whl |
Total release size: 25.4 kB
Release files / aqi_in_api-0.0.2.tar.gz
| Download URL | aqi_in_api-0.0.2.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4810745ae5c8eb64c11db982fa39b7a6f6ac79fc7ddee2bfc841f18610b6e2e8
|
|
BLAKE2b-256 checksum How to use checksums |
9ee9c58388737747c997ae26c91610db3e9e8c8ffca3265e21ec15e6b82fd8e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aqi_in_api-0.0.2-py3-none-any.whl
| Download URL | aqi_in_api-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab8f45a70a8e34cc1e59101570b5cae45a3fbc5c73f0995eb1852941c8794876
|
|
BLAKE2b-256 checksum How to use checksums |
63cb216cd399c9cbcb3b037dde97b3b9e226b5fdaff16715cb01db8e08888ad9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for aqi-in-api 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.