名称: food402
描述: 从土耳其领先的外送服务 TGO Yemek (Trendyol GO) 订购食物。当用户希望在土耳其点外卖、浏览餐厅、搜索食物、管理配送地址、查看订单历史或使用 3D Secure 支付结账时使用。
元数据: {"openclaw": {"emoji": "🍕", "requires": {"bins": ["curl", "jq", "openssl"], "env": ["TGO_EMAIL", "TGO_PASSWORD", "GOOGLE_PLACES_API_KEY"]}, "primaryEnv": "TGO_EMAIL"}}
从土耳其领先的外送服务 Trendyol GO (TGO Yemek) 订购食物。此技能支持完整的外卖点餐流程:浏览餐厅、查看菜单、定制菜品、管理购物车以及使用 3D Secure 支付结账。
将以下内容添加到你的 ~/.openclaw/openclaw.json 文件中:
{
"skills": {
"entries": {
"food402": {
"enabled": true,
"env": {
"TGO_EMAIL": "你的-tgo-邮箱@example.com",
"TGO_PASSWORD": "你的-tgo-密码",
"GOOGLE_PLACES_API_KEY": "你的-google-api-key"
}
}
}
}
}
在你的 shell 配置文件 (~/.bashrc, ~/.zshrc 等) 中设置环境变量:
export TGO_EMAIL="你的-tgo-邮箱@example.com"
export TGO_PASSWORD="你的-tgo-密码"
export GOOGLE_PLACES_API_KEY="你的-google-api-key" # 可选:用于获取 Google 评价
然后重新加载 shell 或运行 source ~/.zshrc (或等效命令)。
此技能会自动处理认证。进行 API 调用时:
{baseDir}/scripts/auth.sh get-token 以获取有效的 JWT。/tmp/food402-token 中,并自动刷新(在过期前 60 秒)。{baseDir}/scripts/auth.sh clear-token 清除令牌并重试。手动认证检查:
{baseDir}/scripts/auth.sh check-token
重要: 你必须遵循以下顺序:
如果 add_to_basket 失败,请先尝试 clear_basket 然后重试。
获取用户保存的配送地址。首先调用此函数以显示可用地址。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-user-apimemberaddress-santral/addresses" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq
响应字段: id, addressName, addressLine, neighborhoodName, districtName, cityName, latitude, longitude
必须在浏览餐厅或添加到购物车之前调用。 为购物车设置配送地址。
参数:
- addressId (必需):来自 get_addresses 的地址 ID。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s -X POST "https://api.tgoapis.com/web-checkout-apicheckout-santral/shipping" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" \
-d '{"shippingAddressId": {addressId}, "invoiceAddressId": {addressId}}'
添加新的配送地址。请先使用 get_cities → get_districts → get_neighborhoods 查找位置 ID。
参数:
- name (必需):名字。
- surname (必需):姓氏。
- phone (必需):不带国家代码的电话号码(例如 "5356437070")。
- addressName (必需):标签(例如 "家"、"公司")。
- addressLine (必需):街道地址。
- cityId (必需):来自 get_cities。
- districtId (必需):来自 get_districts。
- neighborhoodId (必需):来自 get_neighborhoods。
- latitude (必需):坐标字符串。
- longitude (必需):坐标字符串。
- apartmentNumber, floor, doorNumber, addressDescription (可选)。
- elevatorAvailable (可选):布尔值。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s -X POST "https://api.tgoapis.com/web-user-apimemberaddress-santral/addresses" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" \
-d '{
"name": "{name}",
"surname": "{surname}",
"phone": "{phone}",
"addressName": "{addressName}",
"addressLine": "{addressLine}",
"cityId": {cityId},
"districtId": {districtId},
"neighborhoodId": {neighborhoodId},
"latitude": "{latitude}",
"longitude": "{longitude}",
"countryCode": "TR",
"elevatorAvailable": false
}' | jq
注意: 如果响应是 429,则需要 OTP 验证。请引导用户到 tgoyemek.com 添加地址。
获取所有城市列表以供选择地址。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-user-apimemberaddress-santral/cities" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq '.cities[] | {id, name}'
获取指定城市的区。
参数:
- cityId (必需):来自 get_cities 的城市 ID。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-user-apimemberaddress-santral/cities/{cityId}/districts" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq '.districts[] | {id, name}'
获取指定区的街区。
参数:
- districtId (必需):来自 get_districts 的区 ID。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-user-apimemberaddress-santral/districts/{districtId}/neighborhoods" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq '.neighborhoods[] | {id, name}'
列出所选地址附近的餐厅。需要先调用 select_address。
参数:
- latitude (必需):来自所选地址。
- longitude (必需):来自所选地址。
- page (可选):页码,默认为 1。
- sortBy (可选):RECOMMENDED (默认), RESTAURANT_SCORE, 或 RESTAURANT_DISTANCE。
- minBasketPrice (可选):传递 400 以过滤最低订单 >= 400 TL。
排序关键词(土耳其语和英语):
- "önerilen" / "recommended" / "popüler" → RECOMMENDED
- "en yakın" / "closest" / "yakınımdaki" → RESTAURANT_DISTANCE
- "en iyi" / "best rated" / "en yüksek puanlı" → RESTAURANT_SCORE
- "en ucuz" / "cheapest" → 请改用 search_restaurants(返回商品价格)。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-discovery-apidiscovery-santral/restaurants/filters?openRestaurants=true&latitude={latitude}&longitude={longitude}&pageSize=50&page={page}" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq
添加 &sortType=RESTAURANT_SCORE 或 &sortType=RESTAURANT_DISTANCE 进行排序(省略则为 RECOMMENDED)。
响应字段: id, name, kitchen, rating, ratingText, minBasketPrice, averageDeliveryInterval, distance, neighborhoodName, isClosed, campaignText
通过关键词搜索餐厅和商品。结果包含商品价格(对于“最便宜”查询很有用)。
重要: 始终检查 isClosed 字段。切勿推荐已关闭的餐厅。
参数:
- searchQuery (必需):搜索关键词(例如 "pizza", "burger", "dürüm")。
- latitude (必需):来自所选地址。
- longitude (必需):来自所选地址。
- page (可选):页码,默认为 1。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-restaurant-apirestaurant-santral/restaurants/in/search?searchQuery={searchQuery}&latitude={latitude}&longitude={longitude}&pageSize=50&page={page}" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq
响应包含: 餐厅信息以及 products[] 数组,其中包含 id, name, description, price。
获取餐厅的完整菜单,包括分类和商品。
参数:
- restaurantId (必需):餐厅 ID。
- latitude (必需):坐标。
- longitude (必需):坐标。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-restaurant-apirestaurant-santral/restaurants/{restaurantId}?latitude={latitude}&longitude={longitude}" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq
响应结构:
- info:餐厅详情(id, name, rating, workingHours, deliveryTime, minOrderPrice)。
- categories[]:菜单部分,包含 items[](id, name, description, price, likePercentage)。
获取商品定制选项(要排除的配料、用于额外配料/尺寸的修饰组)。
参数:
- restaurantId (必需):餐厅 ID。
- productId (必需):来自菜单的商品 ID。
- latitude (必需):坐标。
- longitude (必需):坐标。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s -X POST "https://api.tgoapis.com/web-restaurant-apirestaurant-santral/restaurants/{restaurantId}/products/{productId}?latitude={latitude}&longitude={longitude}" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" \
-d '{}' | jq
响应包含 components[]:
- type:INGREDIENTS(要排除的项目)或 MODIFIER_GROUP(要选择的额外配料/尺寸)。
- modifierGroupId:向购物车添加修饰时使用此 ID。
- options[]:可用选项,包含 id, name, price, isPopular。
- isSingleChoice, minSelections, maxSelections:选择规则。
获取商品的“搭配推荐”建议。
参数:
- restaurantId (必需):餐厅 ID。
- productIds (必需):商品 ID 数组。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s -X POST "https://api.tgoapis.com/web-discovery-apidiscovery-santral/recommendation/product" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" \
-d '{
"restaurantId": "{restaurantId}",
"productIds": ["{productId1}", "{productId2}"],
"page": "PDP"
}' | jq
将商品添加到购物车。需要先调用 select_address。
参数:
- storeId (必需):餐厅 ID(数字)。
- latitude (必需):坐标(数字,非字符串)。
- longitude (必需):坐标(数字,非字符串)。
- items[] (必需):要添加的商品数组。
商品结构:
{
"productId": 12345,
"quantity": 1,
"modifierProducts": [
{
"productId": 111,
"modifierGroupId": 222,
"modifierProducts": [],
"ingredientOptions": {"excludes": [], "includes": []}
}
],
"ingredientOptions": {
"excludes": [{"id": 333}],
"includes": []
}
}
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s -X POST "https://api.tgoapis.com/web-checkout-apicheckout-santral/carts/items" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" \
-d '{
"storeId": {storeId},
"items": [{items}],
"latitude": {latitude},
"longitude": {longitude},
"isFlashSale": false,
"storePickup": false
}' | jq
如果此操作失败, 请先尝试 clear_basket 然后重试。
获取当前购物车内容。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s "https://api.tgoapis.com/web-checkout-apicheckout-santral/carts" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq
响应包含: storeGroups[](包含店铺信息和商品)、summary[]、totalPrice、deliveryPrice、isEmpty。
从购物车中移除商品。
参数:
- itemId (必需):来自 get_basket 响应的商品 UUID(itemId 字段,不是 productId)。
TOKEN=$({baseDir}/scripts/auth.sh get-token)
curl -s -X DELETE "https://api.tgoapis.com/web-checkout-apicheckout-santral/carts/items/{itemId}" \
-H "Authorization: Bearer $TOKEN" \
-H "x-correlationid: $(uuidgen)" \
-H "pid: $(uuidgen)" \
-H "sid: $(uuidgen)" | jq
清空整个购物车。
```bash
TOKEN=$({baseDir}/scripts/auth.sh