weather-query
84
总安装量
22
周安装量
#5024
全站排名
安装命令
npx skills add https://github.com/vikiboss/60s-skills --skill weather-query
Agent 安装分布
opencode
12
openclaw
10
github-copilot
10
gemini-cli
9
claude-code
9
codex
9
Skill 文档
Weather Query Skill
This skill enables AI agents to fetch real-time weather information and forecasts for locations in China using the 60s API.
When to Use This Skill
Use this skill when users:
- Ask about current weather conditions
- Want weather forecasts
- Need temperature, humidity, wind information
- Request air quality data
- Plan outdoor activities and need weather info
API Endpoints
1. Real-time Weather
URL: https://60s.viki.moe/v2/weather/realtime
Method: GET
2. Weather Forecast
URL: https://60s.viki.moe/v2/weather/forecast
Method: GET
Parameters
location(required): Location name in Chinese- Can be city name: “å京”, “䏿µ·”, “广巔
- Can be district name: “æµ·æ·åº”, “æµ¦ä¸æ°åº”
How to Use
Get Real-time Weather
import requests
def get_realtime_weather(location):
url = 'https://60s.viki.moe/v2/weather/realtime'
response = requests.get(url, params={'location': location})
return response.json()
# Example
weather = get_realtime_weather('å京')
print(f"âï¸ {weather['location']}天æ°")
print(f"ð¡ï¸ 温度ï¼{weather['temperature']}°C")
print(f"ð¨ é£éï¼{weather['wind']}")
print(f"ð§ æ¹¿åº¦ï¼{weather['humidity']}")
Get Weather Forecast
def get_weather_forecast(location):
url = 'https://60s.viki.moe/v2/weather/forecast'
response = requests.get(url, params={'location': location})
return response.json()
# Example
forecast = get_weather_forecast('䏿µ·')
for day in forecast['forecast']:
print(f"{day['date']}: {day['weather']} {day['temp_low']}°C ~ {day['temp_high']}°C")
Simple bash example
# Real-time weather
curl "https://60s.viki.moe/v2/weather/realtime?location=å京"
# Weather forecast
curl "https://60s.viki.moe/v2/weather/forecast?location=䏿µ·"
Response Format
Real-time Weather Response
{
"location": "å京",
"weather": "æ´",
"temperature": "15",
"humidity": "45%",
"wind": "ä¸åé£3级",
"air_quality": "è¯",
"updated": "2024-01-15 14:00:00"
}
Forecast Response
{
"location": "䏿µ·",
"forecast": [
{
"date": "2024-01-15",
"day_of_week": "ææä¸",
"weather": "å¤äº",
"temp_low": "10",
"temp_high": "18",
"wind": "ä¸é£3-4级"
},
...
]
}
Example Interactions
User: “å京ä»å¤©å¤©æ°æä¹æ ·ï¼”
Agent Response:
weather = get_realtime_weather('å京')
response = f"""
âï¸ åäº¬ä»æ¥å¤©æ°
天æ°ç¶åµï¼{weather['weather']}
ð¡ï¸ 温度ï¼{weather['temperature']}°C
ð§ æ¹¿åº¦ï¼{weather['humidity']}
ð¨ é£åï¼{weather['wind']}
ð«ï¸ 空æ°è´¨éï¼{weather['air_quality']}
"""
User: “䏿µ·æªæ¥ä¸å¤©å¤©æ°”
forecast = get_weather_forecast('䏿µ·')
response = "ð
䏿µ·æªæ¥å¤©æ°é¢æ¥\n\n"
for day in forecast['forecast'][:3]:
response += f"{day['date']} {day['day_of_week']}\n"
response += f" {day['weather']} {day['temp_low']}°C ~ {day['temp_high']}°C\n"
response += f" {day['wind']}\n\n"
User: “æ·±å³ä¼ä¸é¨åï¼”
weather = get_realtime_weather('æ·±å³')
if 'é¨' in weather['weather']:
print("â æ¯çï¼æ·±å³ç°å¨æ£å¨ä¸é¨")
print("建议带ä¼åºé¨ï¼")
else:
forecast = get_weather_forecast('æ·±å³')
rain_days = [d for d in forecast['forecast'] if 'é¨' in d['weather']]
if rain_days:
print(f"æªæ¥{rain_days[0]['date']}å¯è½ä¼ä¸é¨")
else:
print("è¿ææ²¡æéé¨é¢æ¥")
Best Practices
-
Location Names: Always use Chinese characters for location names
-
Error Handling: Check if the location is valid before displaying results
-
Context: Provide relevant context based on weather conditions
- Rain: Suggest bringing umbrella
- Hot: Recommend staying hydrated
- Cold: Advise wearing warm clothes
- Poor AQI: Suggest wearing mask
-
Caching: Weather data is updated regularly but can be cached for short periods
-
Fallbacks: If a specific district doesn’t work, try the city name
Common Use Cases
1. Weather-based Recommendations
def give_weather_advice(location):
weather = get_realtime_weather(location)
advice = []
temp = int(weather['temperature'])
if temp > 30:
advice.append("ð¥ 天æ°ççï¼æ³¨æé²æé温ï¼å¤åæ°´")
elif temp < 5:
advice.append("𥶠天æ°å¯å·ï¼æ³¨æä¿æ")
if 'é¨' in weather['weather']:
advice.append("â è®°å¾å¸¦ä¼")
if weather['air_quality'] in ['å·®', 'é度污æ']:
advice.append("ð· 空æ°è´¨éä¸ä½³ï¼å»ºè®®æ´å£ç½©")
return '\n'.join(advice)
2. Multi-city Weather Comparison
def compare_weather(cities):
results = []
for city in cities:
weather = get_realtime_weather(city)
results.append({
'city': city,
'temperature': int(weather['temperature']),
'weather': weather['weather']
})
# Find hottest and coldest
hottest = max(results, key=lambda x: x['temperature'])
coldest = min(results, key=lambda x: x['temperature'])
return f"ð¡ï¸ æç: {hottest['city']} {hottest['temperature']}°C\n" \
f"âï¸ æå·: {coldest['city']} {coldest['temperature']}°C"
3. Travel Weather Check
def check_travel_weather(destination, days=3):
forecast = get_weather_forecast(destination)
suitable_days = []
for day in forecast['forecast'][:days]:
if 'é¨' not in day['weather'] and 'éª' not in day['weather']:
suitable_days.append(day['date'])
if suitable_days:
return f"â
{destination}éååºè¡çæ¥æï¼{', '.join(suitable_days)}"
else:
return f"â ï¸ æªæ¥{days}天{destination}天æ°ä¸å¤ªéååºè¡"
Troubleshooting
Issue: Location not found
- Solution: Try using the main city name instead of district
- Example: Use “å京” instead of “æé³åº”
Issue: No forecast data
- Solution: Verify the location name is correct
- Try standard city names: å京, 䏿µ·, 广å·, æ·±å³, etc.
Issue: Data seems outdated
- Solution: The API updates regularly, but weather can change quickly
- Check the
updatedtimestamp in the response
Supported Locations
The weather API supports most cities and districts in China, including:
- Provincial capitals: å京, 䏿µ·, 广å·, æ·±å³, æé½, æå·, å京, æ¦æ±, etc.
- Major cities: èå·, éå², 大è¿, å¦é¨, etc.
- Districts: æµ·æ·åº, æé³åº, æµ¦ä¸æ°åº, etc.