Iqair airvisual

Learn how to use Iqair airvisual with Composio

Overview

SLUG: IQAIR_AIRVISUAL

Description

IQAir AirVisual provides global air quality data through its API, offering real-time and historical information on air pollution levels.

Authentication Details

generic_key
stringRequired

Connecting to Iqair airvisual

Create an auth config

Use the dashboard to create an auth config for the Iqair airvisual toolkit. This allows you to connect multiple Iqair airvisual accounts to Composio for agents to use.

1

Select App

Navigate to [Iqair airvisual](https://platform.composio.dev?next_page=/marketplace/Iqair airvisual).

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Iqair airvisual Auth Config”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using API Key

1from composio import Composio
2
3# Replace these with your actual values
4iqair_airvisual_auth_config_id = "ac_YOUR_IQAIR_AIRVISUAL_CONFIG_ID" # Auth config ID created above
5user_id = "0000-0000-0000" # UUID from database/app
6
7composio = Composio()
8
9def authenticate_toolkit(user_id: str, auth_config_id: str):
10 # Replace this with a method to retrieve an API key from the user.
11 # Or supply your own.
12 user_api_key = input("[!] Enter API key")
13
14 connection_request = composio.connected_accounts.initiate(
15 user_id=user_id,
16 auth_config_id=auth_config_id,
17 config={"auth_scheme": "API_KEY", "val": {"generic_api_key": user_api_key}}
18 )
19
20 # API Key authentication is immediate - no redirect needed
21 print(f"Successfully connected Iqair airvisual for user {user_id}")
22 print(f"Connection status: {connection_request.status}")
23
24 return connection_request.id
25
26
27connection_id = authenticate_toolkit(user_id, iqair_airvisual_auth_config_id)
28
29# You can verify the connection using:
30connected_account = composio.connected_accounts.get(connection_id)
31print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the [Iqair airvisual toolkit’s playground](https://app.composio.dev/app/Iqair airvisual)

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["IQAIR_AIRVISUAL"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Get Air Quality Forecast Data

Description

Tool to retrieve air quality forecast data for a specified city, state, and country. Use after confirming location details.

Action Parameters

city
stringRequired
country
stringRequired
state
stringRequired

Action Response

data
objectRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get Cities

Description

Tool to list supported cities in a specified state and country. Use when you need to retrieve cities for a given state/country.

Action Parameters

country
stringRequired
state
stringRequired

Action Response

data
arrayRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get City Air Quality

Description

Tool to retrieve air quality data for a specific city. Use when you need current pollution and weather data by specifying city, state, and country.

Action Parameters

city
stringRequired
country
stringRequired
state
stringRequired

Action Response

data
objectRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get supported countries

Description

Tool to list all supported countries. Use when you need to know which countries are supported by the AirVisual API.

Action Parameters

Action Response

data
arrayRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get Historical AQI Data

Description

Tool to retrieve historical air quality data for a city. Use after confirming city, state, and country when you need AQI readings over time.

Action Parameters

city
stringRequired
country
stringRequired
end
string
start
string
state
stringRequired

Action Response

data
objectRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get Nearest City Air Quality

Description

Tool to retrieve air quality data for the nearest city based on latitude/longitude or IP. Use when you have precise location data or want to geolocate an IP for air quality.

Action Parameters

ip
string
lat
number
lon
number

Action Response

data
objectRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get Nearest Station Air Quality

Description

Tool to get nearest station air quality. Use when you have GPS coordinates and need closest station’s AQI.

Action Parameters

lat
numberRequired
lon
numberRequired

Action Response

data
objectRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get States

Description

Tool to list supported states in a specified country. Use when you need to retrieve states/provinces for a given country.

Action Parameters

country
stringRequired

Action Response

data
arrayRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get Station by ID

Description

Tool to fetch air quality and weather data for a specific monitoring station by ID. Use when you need detailed historical, current, and forecast data for a station.

Action Parameters

city
stringRequired
country
stringRequired
state
stringRequired
station
stringRequired

Action Response

data
objectRequired
error
string
status
stringRequired
successful
booleanRequired

Tool Name: Get World AQI Rankings

Description

Tool to retrieve a ranking of cities worldwide based on current AQI. Use when you need a global AQI ranking list after authenticating with a valid AirVisual API key. If /world-rankings is not accessible, gracefully falls back to /nearest_city and returns a single-item list based on the nearest city.

Action Parameters

ip
string
lat
number
lon
number

Action Response

data
arrayRequired
error
string
status
stringRequired
successful
booleanRequired