Openweather api

Learn how to use Openweather api with Composio

Overview

SLUG: OPENWEATHER_API

Description

Provides access to current weather data, forecasts, and historical weather data for any location worldwide.

Authentication Details

generic_api_key
stringRequired

Connecting to Openweather api

Create an auth config

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

1

Select App

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

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 Openweather api 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
4openweather_api_auth_config_id = "ac_YOUR_OPENWEATHER_API_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 Openweather api 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, openweather_api_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 [Openweather api toolkit’s playground](https://app.composio.dev/app/Openweather api)

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=["OPENWEATHER_API"])
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: Delete Weather Station

Description

Tool to delete a registered weather station. use after identifying a station to remove. returns confirmation message upon success.

Action Parameters

station_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get 5 Day Forecast

Description

Tool to get a 5-day forecast every 3 hours. use after specifying location.

Action Parameters

id
integer
lang
string
lat
number
lon
number
mode
string
q
string
units
string
zip
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Current Air Pollution Data

Description

Tool to fetch current air pollution data for a location. use when you need real-time air quality details by latitude and longitude.

Action Parameters

lat
numberRequired
lon
numberRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Air Pollution Forecast

Description

Tool to get forecasted air pollution data for a specific location. use after confirming latitude and longitude.

Action Parameters

lat
numberRequired
lon
numberRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Air Pollution History

Description

Tool to retrieve historical air pollution data. use when you need past air quality levels for a specific latitude/longitude and time range.

Action Parameters

end
integerRequired
lat
numberRequired
lon
numberRequired
start
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Circle City Weather

Description

Tool to search for current weather data in cities around a geographic point. use when you need to fetch weather within a radius circle after confirming latitude and longitude.

Action Parameters

cnt
integer
lang
stringDefaults to en
lat
numberRequired
lon
numberRequired
mode
stringDefaults to json
units
stringDefaults to standard

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Current Weather

Description

Tool to retrieve current weather data for a location. use when you need up-to-the-minute weather info.

Action Parameters

id
integer
lang
string
lat
number
lon
number
q
string
units
string
zip
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Direct Geocoding

Description

Tool to convert a location name into geographic coordinates. use when you need latitude and longitude for a given location after confirming the precise name.

Action Parameters

limit
integerDefaults to 5
q
stringRequired

Action Response

data
arrayRequired
error
string
successful
booleanRequired

Tool Name: Get Reverse Geocoding

Description

Tool to convert geographic coordinates into a location name. use when you need city, state, and country info from latitude and longitude.

Action Parameters

lat
numberRequired
limit
integer
lon
numberRequired

Action Response

data
arrayRequired
error
string
successful
booleanRequired

Tool Name: Get Current UV Index

Description

Tool to retrieve current uv index for a location. use when you need up-to-the-minute uv index by latitude and longitude.

Action Parameters

lat
numberRequired
lon
numberRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get UV Index Forecast

Description

Tool to retrieve uv index forecast for a specific location. use when you need upcoming uv index values after confirming latitude and longitude. returns up to 8 days of data.

Action Parameters

cnt
integer
lat
numberRequired
lon
numberRequired

Action Response

data
arrayRequired
error
string
successful
booleanRequired

Tool Name: Get UV Index History

Description

Tool to retrieve historical uv index data for a specified location and time range. use when you need to analyze past uv exposure trends after confirming coordinates and time period.

Action Parameters

end
integerRequired
lat
numberRequired
lon
numberRequired
start
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Weather Map Tile (2.0)

Description

Tool to fetch weather maps 2.0 tile images. use when you need dynamic weather layers at specific zoom and coordinates with advanced styling options.

Action Parameters

color
string
fill
string
fill_bound
boolean
format
string
layer
stringRequired
opacity
number
palette
string
scale
integer
x
integerRequired
y
integerRequired
z
integerRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Weather Stations

Description

Tool to list all weather stations added to your account. use after setting up your openweather api key.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Weather Triggers

Description

Tool to retrieve weather triggers for specific conditions. use after defining trigger criteria.

Action Parameters

triggers
arrayRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Add Weather Station

Description

Tool to add a new weather station to your account. use when you need to register a station before sending custom data.

Action Parameters

altitude
numberRequired
external_id
stringRequired
latitude
numberRequired
longitude
numberRequired
name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Update Weather Station

Description

Tool to update weather station details. use when you need to modify the name, location, or external id of an existing station.

Action Parameters

altitude
number
external_id
string
latitude
numberRequired
longitude
numberRequired
name
string
station_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired