Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
pyairvisual
is a simple, clean, well-tested library for interacting with
AirVisual to retrieve air quality information.
pyairvisual
is currently supported on:
pip install pyairvisual
You can get an AirVisual API key from the AirVisual API site. Depending on the plan you choose, more functionality will be available from the API:
The Community Plan gives access to:
The Startup Plan gives access to:
The Enterprise Plan gives access to:
import asyncio
from pyairvisual.cloud_api import CloudAPI
async def main() -> None:
"""Run!"""
cloud_api = CloudAPI("<YOUR_AIRVISUAL_API_KEY>")
# Get data based on the city nearest to your IP address:
data = await cloud_api.air_quality.nearest_city()
# ...or get data based on the city nearest to a latitude/longitude:
data = await cloud_api.air_quality.nearest_city(
latitude=39.742599, longitude=-104.9942557
)
# ...or get it explicitly:
data = await cloud_api.air_quality.city(
city="Los Angeles", state="California", country="USA"
)
# If you have the appropriate API key, you can also get data based on
# station (nearest or explicit):
data = await cloud_api.air_quality.nearest_station()
data = await cloud_api.air_quality.nearest_station(
latitude=39.742599, longitude=-104.9942557
)
data = await cloud_api.air_quality.station(
station="US Embassy in Beijing",
city="Beijing",
state="Beijing",
country="China",
)
# With the appropriate API key, you can get an air quality ranking:
data = await cloud_api.air_quality.ranking()
# pyairvisual gives you several methods to look locations up:
countries = await cloud_api.supported.countries()
states = await cloud_api.supported.states("USA")
cities = await cloud_api.supported.cities("USA", "Colorado")
stations = await cloud_api.supported.stations("USA", "Colorado", "Denver")
asyncio.run(main())
By default, the library creates a new connection to AirVisual with each coroutine. If
you are calling a large number of coroutines (or merely want to squeeze out every second
of runtime savings possible), an aiohttp
ClientSession
can be used for
connection pooling:
import asyncio
from aiohttp import ClientSession
from pyairvisual.cloud_api import CloudAPI
async def main() -> None:
"""Run!"""
async with ClientSession() as session:
cloud_api = CloudAPI("<YOUR_AIRVISUAL_API_KEY>", session=session)
# ...
asyncio.run(main())
pyairvisual
also allows users to interact with Node/Pro units, both via
the cloud API:
import asyncio
from aiohttp import ClientSession
from pyairvisual.cloud_api import CloudAPI
async def main() -> None:
"""Run!"""
cloud_api = CloudAPI("<YOUR_AIRVISUAL_API_KEY>")
# The Node/Pro unit ID can be retrieved from the "API" section of the cloud
# dashboard:
data = await cloud_api.node.get_by_node_id("<NODE_ID>")
asyncio.run(main())
...or over the local network via Samba (the unit password can be found on the device itself):
import asyncio
from aiohttp import ClientSession
from pyairvisual.node import NodeSamba
async def main() -> None:
"""Run!"""
async with NodeSamba("<IP_ADDRESS_OR_HOST>", "<PASSWORD>") as node:
measurements = await node.async_get_latest_measurements()
# Can take some optional parameters:
# 1. include_trends: include trends (defaults to True)
# 2. measurements_to_use: the number of measurements to use when calculating
# trends (defaults to -1, which means "use all measurements")
history = await node.async_get_history()
asyncio.run(main())
Check out the examples, the tests, and the source files themselves for method signatures and more examples.
Thanks to all of our contributors so far!
python3 -m venv .venv
source ./.venv/bin/activate
script/setup
poetry run pytest --cov pyairvisual tests
README.md
with any new documentation.FAQs
A simple API for AirVisual air quality data
We found that pyairvisual demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.