← 返回
未分类 中文

Divar Api

Use this skill whenever the user wants to search, query, or extract data from Divar (divar.ir) — Iran's largest classifieds platform. Triggers include: searc...
在用户需要从伊朗最大分类平台Divar(divar.ir)搜索、查询或提取数据时使用此技能。触发词包括:搜索。
hadifarnoud
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 323
下载
💾 0
安装
1
版本
#latest

概述

Divar API Skill

Divar uses a server-driven widget API (JSON over HTTPS, protobuf type annotations embedded via @type).

All responses are lists of typed widget_type objects. Base URL: https://api.divar.ir.

Critical: form_data field types

Every filter field uses a typed wrapper. Wrong type = HTTP 400. Use this table exactly:

FieldWrapperExample
-------------------------
categorystr{ "str": { "value": "residential-rent" } }
sortstr{ "str": { "value": "sort_date" } }
districtsrepeated_string{ "repeated_string": { "value": ["920", "82"] } }
roomsrepeated_string{ "repeated_string": { "value": ["یک", "دو"] } }
rentnumber_range{ "number_range": { "minimum": "20000000", "maximum": "60000000" } }
creditnumber_range{ "number_range": { "minimum": "300000000", "maximum": "600000000" } }
sizenumber_range{ "number_range": { "minimum": "80", "maximum": "120" } }
balconyboolean{ "boolean": { "value": true } }
parkingboolean{ "boolean": { "value": true } }

> number_range min/max values are strings, not numbers.

> boolean value is a JS boolean (true/false), not a string.

Critical: category slugs

The API slug differs from the divar.ir URL path segment. Never use the URL segment as the slug.

API slug (category.str.value)URL pathPersian
----------------------------------------------------
residential-rentrent-residentialاجاره مسکونی
apartment-sellapartment-sellفروش آپارتمان
apartment-rentrent-apartmentاجاره آپارتمان
buy-residentialbuy-residentialفروش مسکونی
real-estatereal-estateهمه ملک
buy-commercial-propertybuy-commercial-propertyفروش اداری/تجاری
rent-commercial-propertyrent-commercial-propertyاجاره اداری/تجاری
rent-temporaryrent-temporaryاجاره کوتاه‌مدت

When in doubt, intercept a real browser request via DevTools to read the actual category.str.value.

Search endpoint

POST /v8/postlist/w/search

Verified working payload (residential rental, Tehran, tested 2026-04-01 → returned 24 listings):

{
  "city_ids": ["1"],
  "source_view": "SEARCH",
  "disable_recommendation": false,
  "search_data": {
    "form_data": {
      "data": {
        "category":  { "str":            { "value": "residential-rent" } },
        "districts": { "repeated_string": { "value": ["139","143","145","4162","75","78","82","920","921"] } },
        "rooms":     { "repeated_string": { "value": ["دو","یک"] } },
        "rent":      { "number_range":   { "minimum": "20000000",  "maximum": "60000000"  } },
        "credit":    { "number_range":   { "minimum": "300000000", "maximum": "600000000" } },
        "size":      { "number_range":   { "minimum": "80",        "maximum": "120"       } },
        "balcony":   { "boolean":        { "value": true } },
        "parking":   { "boolean":        { "value": true } }
      }
    },
    "server_payload": {
      "@type": "type.googleapis.com/widgets.SearchData.ServerPayload",
      "additional_form_data": {
        "data": { "sort": { "str": { "value": "sort_date" } } }
      }
    }
  }
}

Response: { "list_top_widgets": [...], "list_widgets": [...] }

Filter to widget_type === "POST_ROW" to get listings. Each POST_ROW has:

  • data.title — listing title (Persian)
  • data.middle_description_text — price string
  • data.bottom_description_text — relative time ("دقایقی پیش")
  • data.action.payload.token — unique post ID (use for detail/contact endpoints)
  • data.action.payload.web_info.district_persian — district name
  • data.image_count — number of photos

Pagination

Cursor-based. On page 1, no pagination_data. On page 2+, add:

{
  "pagination_data": {
    "@type": "type.googleapis.com/post_list.PaginationData",
    "last_post_date": "<ISO8601 from previous last post>",
    "page": 2,
    "layer_page": 2,
    "search_uid": "<uuid — keep constant for the session>",
    "cumulative_widgets_count": 24
  }
}

viewed_tokens is an optional gzip+base64 bloom filter for server-side deduplication — safe to omit.

Post detail

GET /v8/posts-v2/web/{token}

Returns sections (BREADCRUMB, HEADER, IMAGES, DETAILS) each containing widget arrays.

Common detail widget types: KEY_VALUE (room count, floor, etc.), DESCRIPTION, IMAGE_GALLERY, MAP.

Contact info (requires auth)

POST /v8/postcontact/web/contact_info_v2/{token}

Body: {}. Returns widget_list with UNEXPANDABLE_ROW containing phone number.

Returns RBAC: access denied without authentication.

Authentication

  • Cookie-based: token cookie + did (device ID) cookie, set by divar.ir on login.
  • Header: Authorization: Basic — same JWT value as the token cookie.
  • The search endpoint works with session cookies alone when called same-origin from divar.ir.
  • Cross-origin calls (e.g. from a script) need the Authorization header explicitly.

Parsing a divar.ir search URL → API payload

When a user pastes a URL like:

https://divar.ir/s/tehran/rent-residential/almahdi?balcony=true&credit=300000000-600000000&districts=920%2C82&rent=20000000-60000000&rooms=%D8%AF%D9%88%2C%DB%8C%DA%A9&size=80-120

Map query params to form_data fields:

URL paramform_data fieldWrapper
------------------------------------
URL path segment (e.g. rent-residential)category → look up API slugstr
districts=920,82,...districtsrepeated_string (split on ,)
rooms=دو,یکroomsrepeated_string (split on ,)
rent=min-maxrentnumber_range (split on -)
credit=min-maxcreditnumber_range (split on -)
size=min-maxsizenumber_range (split on -)
balcony=truebalconyboolean
parking=trueparkingboolean
map_bbox=...not in form_data — belongs in /v8/mapview/viewport camera_info.bbox
map_place_hash=...not in form_data

For full API reference (all endpoints, widget system, map/geo, autocomplete, filters):

→ read references/api-reference.md

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 12:28 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,211 📥 266,215
developer-tools

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 668 📥 323,846
ai-intelligence

self-improving agent

pskoett
捕获经验教训、错误和纠正,以实现持续改进。使用时机:(1)命令或操作意外失败;(2)用户纠正……
★ 4,056 📥 796,451