Weather Search

👤 george-china 📦 v1.0.0 ⭐ 0.0 ⬇️ 535 下载
🏠 生活服务 免费 🔑 需 API Key

📖 技能介绍

Weather Search Skill

Query real-time weather information using Amap (高德地图) Weather API.

API Documentation

https://lbs.amap.com/api/javascript-api/guide/services/weather

Prerequisites

  1. Get Amap API Key

  2. Set Environment Variable

    export AMAP_API_KEY="your_api_key_here"

Usage

发现更多技能插件,请访问7w4.net。

Query Weather by City Name

curl -X GET "https://restapi.amap.com/v3/weather/weatherInfo?city=BEIJING&key=YOUR_API_KEY&output=json"

Query Weather by City Code

curl -X GET "https://restapi.amap.com/v3/weather/weatherInfo?city=110000&key=YOUR_API_KEY&output=json"

Query Multiple Cities

curl -X GET "https://restapi.amap.com/v3/weather/weatherInfo?city=BEIJING|SHANGHAI|GUANGZHOU&key=YOUR_API_KEY&output=json"

Query by Coordinates (Latitude, Longitude)

curl -X GET "https://restapi.amap.com/v3/weather/weatherInfo?location=116.40,39.90&key=YOUR_API_KEY&output=json"

API Parameters

Parameter Type Required Description
city String Yes (or location) City name or city code
location String Yes (or city) Format: longitude,latitude
key String Yes Amap API Key
output String No Response format: json or xml (default: json)

Response Example

{
  "status": "1",
  "infocode": "10000",
  "info": "Query Successful",
  "count": "1",
  "lives": [
    {
      "province": "Beijing",
      "city": "Beijing",
      "adcode": "110000",
      "weather": "Clear",
      "temperature": "25",
      "winddirection": "North",
      "windpower": "2",
      "humidity": "45",
      "reporttime": "2024-01-15 12:00:00"
    }
  ]
}

Quick Start Script

Create a weather query script:

#!/bin/bash
# weather.sh

API_KEY="${AMAP_API_KEY:-your_api_key_here}"
CITY="$1"

if [ -z "$CITY" ]; then
    echo "Usage: weather.sh <city_name_or_code>"
    exit 1
fi

curl -s "https://restapi.amap.com/v3/weather/weatherInfo?city=${CITY}&key=${API_KEY}&output=json" | jq '.'

Make it executable:

chmod +x weather.sh
./weather.sh BEIJING

City Code Reference

City Code
Beijing 110000
Shanghai 310000
Guangzhou 440100
Shenzhen 440300
Hangzhou 330100
Chengdu 510100
Wuhan 420100
Xi'an 610100

Notes

  • API Key is required for all requests
  • Free tier: 1000 requests/day
  • Response includes: weather condition, temperature, wind direction, wind power, humidity
  • Supports both Chinese city names and city codes

📁 包含文件 (3 个)

📄 SKILL.md 3 KB
📄 _meta.json 133 B
📄 weather.sh 1.5 KB