Python SDK for the Amap (高德地图) Web Service REST API.
Disclaimer: This is an unofficial, community-maintained SDK. 高德地图 is a trademark of AutoNavi Software Co., Ltd. (Alibaba Group). This project is not affiliated with or endorsed by Amap/AutoNavi.
- 10 API modules covering geocoding, POI search, routing, weather, and more
- POI search uses the latest v5 API
- Type-annotated, minimal dependencies (
requestsonly) - Comprehensive test suite (68 unit + 4 integration tests)
pip install amap-sdkFor development:
git clone https://github.com/Horacehxw/amap-sdk-python.git
cd amap-sdk-python
pip install -e ".[dev]"fromamapimportAmapClient# Via environment variable AMAP_MAPS_KEY, or pass directly:client=AmapClient(api_key="your_api_key")
# Geocodingresult=client.geocoding.geocode("北京市朝阳区阜通东大街6号")
# POI search (v5)pois=client.poi.text_search("火锅", city="重庆")
# Weatherweather=client.weather.get_weather("110101") # adcode for 东城区# Routingroute=client.direction.driving("116.481028,39.989643", "116.465302,40.004717")
# Static map (returns PNG bytes)img=client.staticmap.get_map(location="116.481028,39.989643", zoom=15)Get your API key from the Amap Developer Portal.
| Module | Attribute | Description |
|---|---|---|
| Geocoding | client.geocoding | Address ↔ coordinate conversion |
| POI (v5) | client.poi | Place search: text, nearby, polygon, detail |
| Weather | client.weather | Current weather and forecasts |
| District | client.district | Administrative region queries |
| Input Tips | client.inputtips | Search autocomplete suggestions |
| Distance | client.distance | Distance measurement between points |
| Direction | client.direction | Walk, drive, transit, bicycle routing |
| Static Map | client.staticmap | Static map image generation (PNG) |
| Coordinate | client.coordinate | Coordinate system conversion (GPS/Baidu → GCJ-02) |
| Traffic | client.traffic | Real-time traffic status (road, circle, rectangle) |
# Unit tests (no API key needed)
pytest -v
# Skip integration tests
pytest -v -m "not integration"# Integration tests (requires real API key)
AMAP_MAPS_KEY=your_key pytest -v -m integration高德地图 Web Service REST API 的 Python SDK,覆盖地理编码、POI 搜索、路线规划、天气查询等 10 个模块。
安装:
pip install amap-sdk特性:
- POI 搜索使用最新 v5 API
- 完整类型注解,仅依赖
requests - 72 个测试(68 单元 + 4 集成),无需 API Key 即可运行单元测试
- 支持坐标系转换(GPS/百度 → GCJ-02)
使用前需要: 在高德开放平台注册并获取 API Key。