开发文档
Avito.ma API 参考:搜索、详情与查询
Avito.ma API 参考文档:说明广告搜索各输入如何组合,如何确定要读取详情的广告,以及分类、城市和广告字段的含义。
另见: Avito.ma 摩洛哥分类信息 API 概览与价格 · Avito.ma API 指南:从分类到广告详情
本页内容
Avito.ma API 分类:行与语言
avito-ma-categories 只有一个输入 body.lang,用来选择名称的语言。无法识别的值会被忽略并采用默认值,avito-ma-detail、avito-ma-locations 和 avito-ma-search 上的 body.lang 遵循同样的规则。
在 categories[] 中,category_id 是 avito-ma-search 的 body.category 所需要的编号。name 字段是所选语言下的标签,url_slug 是 Avito 在自己地址中使用的短名。children[] 列表保存节点之下的分支,所以读取这棵树需要逐级向下。
ad_type 字段把节点归为 sell、let、vac_rent 或 co_rent。search_ad_type 字段是对应的 body.ad_type 取值,所以要指定某一棵树时,请把它与 category_id 配对使用。
本节涉及的字段(2)
avito-ma-categories, body.lang
详情:确定广告
avito-ma-detail 通过 body.list_id(广告地址末尾的编号)或 body.url 确定广告,body.url 既接受以 .htm 结尾的短地址,也接受较长的友好地址。搜索行已经给出编号时,使用 body.list_id。
id 和 ad_id 可作为 body.list_id 的替代名称。如果 body.list_id 或 body.url 的值不被识别,该值会被忽略,改用默认值。
已删除或已过期的广告会返回未找到,因为该操作会识别 Avito 把它们的地址重定向到的搜索页。
本节涉及的字段(3)
avito-ma-detail, body.list_id, body.url
详情:listing 内的字段
listing 对象把 Avito 自己的代码放在搜索所返回的值旁边。ad_type 是 SELL、LET、VAC_RENT 或 CO_RENT,而 ad_type_code 保存页面自己使用的字母 s、u、v 或 w,ad_type_label 保存可读的名称。同样,seller_type 是 STORE 或 PRIVATE,seller_type_code 保存页面自己使用的 shop 或 private。
phone 保存页面公布的电话,Avito 隐藏电话时为 null,has_hidden_phone 显示电话是否被隐藏。price_matches_display 显示数字 price 与 price_display 是否一致,old_price 与 old_price_display 带有此前的价格。
attributes[] 的每一行把 label 与 value 及其 display 形式配成一对。unit、section、code 和 id 字段补充这一行的单位、分组、代码和标识。
印出名称背后的编号是 city_id、area_id 和 category_id,latitude、longitude 和 address 用来定位广告。
本节涉及的字段(2)
avito-ma-detail, data
地点:缩小城市列表
body.city 把 avito-ma-locations 的结果缩小到一个城市及其地区。它接受短名、名称或编号,city_id 和 city_slug 可作为替代名称。body.city 填入无法识别的值时,该值被忽略并由默认值接替;省略该输入则返回整份列表。
在每个 cities[] 条目中,slug 是 avito-ma-search 的 body.city 所取的值。ad_count 字段是该城市中的广告数量。areas[] 列表保存它的地区及其 area_id、name 和 slug,地区短名就是 body.area 的取值。
body.lang 在法语和阿拉伯语之间切换印出的城市和地区名称。
本节涉及的字段(3)
avito-ma-locations, body.city, body.lang
Avito.ma API 搜索:关键词、分类与广告类型
avito-ma-search 至少需要 body.q 和 body.category 之一。搜索覆盖站内的所有垂直领域,包括手机、汽车、公寓、家具、招聘和服务。关键词是自由文本,与法语或阿拉伯语的广告标题和正文匹配,例如 iphone、appartement 或 voiture occasion,query、keyword 和 search 可作为替代名称。
分类可以是 1000 这样的根节点,也可以是 5010 这样的叶子节点,category_id 可作为替代名称。body.q 或 body.category 的值无法识别时,会被忽略并采用默认值。
若干房产编号由出售、出租、度假租赁和合租几棵树共用。body.ad_type 在其中选择,省略时使用出售树。
对于分类 1010,rent 对应 1300 树,holiday_rent 对应 1500 树,shared_rent 对应 1400 树;rent 也适用于汽车,其中分类 2100 是汽车租赁,并适用于卡车。名称 type 可作为替代名称,四个取值之外的值会被忽略。
该操作会拒绝两种组合,而不是以错误的广告类型作答:
body.ad_type取 rent、holiday_rent 或 shared_rent 却没有body.category,因为跨分类的关键词搜索不按广告类型筛选body.category在所选广告类型下不存在,例如 5010 手机搭配 rent
本节涉及的字段(4)
avito-ma-search, body.q, body.category, body.ad_type
搜索:地点、价格、卖家与翻页
body.city 接受短名或去掉重音符号的名称,所以 Fès 变成 fes,Béni Mellal 变成 beni_mellal。名称 city_slug 和 ville 同样被接受,作用与 body.city 相同。Avito 不认识的城市会被拒绝,而不会放宽为整个国家的搜索。
body.area 是所选城市中的一个地区,需要同时给出 body.city;maarif 或 medina_de_rabat 这样的短名来自 avito-ma-locations。body.area 给出无法识别的地区时会被忽略,默认值照常适用,area_slug、district 和 secteur 可作为替代名称。
body.price_min 和 body.price_max 按广告所用货币的价格筛选,摩洛哥迪拉姆印作 DH,两者可以只给一个。body.seller_type 把结果限制为个人卖家,或限制为职业卖家和店铺,每一行都会回显自己的 seller_type。
body.ad_options 取 Avito 自己的广告标记之一,ad_option 可作为替代名称:
has_price:只保留公布价格的广告has_image:只保留带照片或视频的广告hotdeal:只保留被标记为促销的广告urgent:只保留卖家标为紧急的广告
body.page 选择 Avito 自己结果列表中的一页。每页约有 35-38 行,没有任何输入能改变它,内容不断变化的结果流中,相邻页会有一两行重叠。页码值无法识别时回退为默认值。
本节涉及的字段(8)
avito-ma-search, body.city, body.area, body.price_min, body.price_max, body.seller_type, body.ad_options, body.page
搜索:listings 与 projects 内的字段
listings[] 的每一行通过 ad_id、list_id 和 url 标识广告。它的位置来自 city_id、city、area_id、area 和 address。地图位置来自 latitude 和 longitude。
seller 对象分三组阅读:
seller_id、name、logo和website用来标识并展示卖家registered_since和active_listings_count描述账号的起始时间及活跃广告数量is_verified、is_ecommerce、phone_verified和phone_contact_type描述卖家的状态与电话联系方式
category_path[] 列表保存广告上方的各级分类,每一级由 id 和 name 组成。phone 字段保存卡片公布的电话,image 是单张图片,images[] 是图片列表,image_count 给出它的数量。
projects[] 中的卡片描述楼盘。卡片的 kind 和 title 为它命名,url 指向该项目。
city 和 area 字段标明位置,price、price_display 和 currency 给出价格。rooms、bathrooms 和 size 字段分别给出房间数、卫生间数和面积,image 展示楼盘。
本节涉及的字段(2)
avito-ma-search, data
操作
公共网关操作统一使用 POST /api/v1/{project}/{action}。
使用 JSON 对象,按文档将参数放入 path、query、headers 和 body,省略未使用的位置。input.headers 是供操作使用的 JSON 数据,不是浏览器请求头。请勿在此填写凭证。按文档保留 body 的数组、标量或 null;省略与 null 含义不同。
分类树
POST /api/v1/avito-ma/avito-ma-categories
列出 Avito.ma 的分类树,含编号、名称、广告类型和 URL 短名,名称可用法语或阿拉伯语。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.lang | string | 可选 | "fr" | "fr""ar" | — |
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/avito-ma/avito-ma-categories' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"lang":"fr"}}'广告详情
POST /api/v1/avito-ma/avito-ma-detail
按 list_id 或广告地址返回单条广告:正文、价格、位置、卖家、电话、图片和属性行。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.lang | string | 可选 | "fr" | "fr""ar" | — |
body.list_id | string | 可选 | — | — | — |
body.url | string | 可选 | — | — | — |
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/avito-ma/avito-ma-detail' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"url":"https://www.avito.ma/vi/56251043.htm"}}'城市与地区
POST /api/v1/avito-ma/avito-ma-locations
列出摩洛哥的城市和乡镇及其短名、广告数量和地区,也可只取某一个城市。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.city | string | 可选 | — | — | — |
body.lang | string | 可选 | "fr" | "fr""ar" | — |
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/avito-ma/avito-ma-locations' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"city":"casablanca"}}'广告搜索
POST /api/v1/avito-ma/avito-ma-search
按关键词或分类搜索广告,可按城市、地区、价格、卖家类型和广告标记筛选。
输入字段
| 字段 | 类型 | 是否必填 | 默认值 | 允许的值 | 范围限制 |
|---|---|---|---|---|---|
body.ad_options | string | 可选 | — | "has_price""has_image""hotdeal""urgent" | — |
body.ad_type | string | 可选 | "sell" | "sell""rent""holiday_rent""shared_rent" | — |
body.area | string | 可选 | — | — | — |
body.category | integer | 可选 | — | — | -9007199254740991–9007199254740991 |
body.city | string | 可选 | — | — | — |
body.lang | string | 可选 | "fr" | "fr""ar" | — |
body.page | integer | 可选 | 1 | — | 1–9007199254740991 |
body.price_max | integer | 可选 | — | — | 0–9007199254740991 |
body.price_min | integer | 可选 | — | — | 0–9007199254740991 |
body.q | string | 可选 | — | — | — |
body.seller_type | string | 可选 | — | "private""professional" | — |
请求示例
# Server-side only. Set KAKIAPI_API_KEY in your secret manager.
# Every gateway operation is called with POST.
# Only operations shown as enabled on the API page can be called.
# Generate once per intent; retain the same value on status checks.
REQUEST_ID="$(uuidgen)"
curl --request POST 'https://kakiapi.com/api/v1/avito-ma/avito-ma-search' \
--header "Content-Type: application/json" \
--header "x-api-key: $KAKIAPI_API_KEY" \
--header "Idempotency-Key: $REQUEST_ID" \
--data '{"body":{"category":5010,"q":"iphone"}}'调用方式
- 使用
POST /api/v1/avito-ma/<action>,并携带x-api-key、Content-Type: application/json和必需的Idempotency-Key。 - 调用成功时返回
ok: true:data是操作的结果,meta.requestId标识已记录的请求,meta.chargedCreditUnits是实际扣费金额。否则ok为false,error.code说明原因;请读取ok和error.code,不要只依赖 HTTP 状态码。每个网关响应都带有供支持使用的请求 ID:meta.requestId;没有meta的响应(如受理前被拒绝)则为顶层requestId。 - 只有调用成功才按标价扣费。失败不扣费;结果无法确认时,最多 900 秒后释放,不扣费。
- 请求完成后,以同一个 Idempotency-Key 重复发送相同请求,24 小时内返回已保存的响应,不会再次扣费。
网关调用参考: