راهنمای اتصال

مستندات API

تخمین فوری، میانگین محله و تحقیق غیرهمزمان ملک. همه قیمت‌ها به تومان هستند.

OpenAPI JSON

لینک آماده برای AI

این لینک را همراه کلید API به دستیار خود بدهید تا قرارداد ورودی و خروجی را بخواند.

/llms.txt ↗
# Bamelak AI — Private Tehran Property Pricing API
Version: 1.9.0
Base URL: https://ai.bamelak.com
OpenAPI: https://ai.bamelak.com/api/openapi
Human documentation: https://ai.bamelak.com/api-docs

## Authentication
All /api/v1 endpoints require Authorization: Bearer <API_KEY>.
An administrator creates and revokes keys at https://ai.bamelak.com/api-dashboard.
API keys cannot access the admin panel or start district discovery/update jobs. Keys may create and read their own property research jobs.
Send Content-Type: application/json. Limit: 60 requests per minute per key; maximum body 16KB.
Never put credentials in the URL or JSON body. Request/response logs are retained for 90 days.
Every price is in TOMAN (not IRR/rial). Area is in square meters. Coordinates use WGS84 decimal latitude/longitude.
Coverage: Tehran municipal districts 1, 2, 3 and 4 only.

## POST /api/v1/estimate
Required: latitude (number), longitude (number), area (positive number <=10000), propertyType (apartment|house|land).
Optional district: "1"|"2"|"3"|"4". It must agree with coordinates; the server determines district using stored approximate municipal polygons.
Optional numeric fields: buildingAge (0..150), bedrooms (0..20), bathrooms (0..20), floor (-10..100), totalFloors (1..100), parkingSpaces (0..20), landArea (positive <=100000).
Optional boolean fields: elevator, parking, storage, renovated, balcony, swimmingPool, saunaJacuzzi, gym, lobby, concierge, roofGarden, centralCooling, premiumView.
Optional neighborhood: string <=80 characters. Omitted features use the existing model defaults.
For land, landArea takes precedence over area for total price.
Example input: {"latitude":35.769,"longitude":51.453,"area":100,"propertyType":"apartment","buildingAge":10,"parking":true,"elevator":true}
Success: {"requestId":"UUID","data":{"calculationId":"...","pricingMode":"calibrated-model|sample-based","district":"3","currency":"toman","area":100,"price":{"minimum":NUMBER,"middle":NUMBER,"maximum":NUMBER},"pricePerM2":{"minimum":NUMBER,"middle":NUMBER,"maximum":NUMBER},"confidence":"low|medium|high","calibrationSampleCount":NUMBER,"createdAt":"ISO8601","disclaimer":"..."}}
Uses the current calibrated model, active local observations and nearby market evidence. Sparse evidence can yield low confidence; do not call this a verified transaction price.

## راهنمای ایجنت سایت: پرسش جزئیات و مشاعات
برای تخمین یک ملک، از POST /api/v1/estimate استفاده کنید. قیمت میانگین محله با /api/v1/neighborhood-price یک شاخص عمومی است و مشخصات واحد و مشاعات را دریافت نمی‌کند.
ابتدا موقعیت نقشه، متراژ و نوع ملک را بگیرید؛ سپس مشخصات بنا، امکانات و مشاعات را مرحله‌به‌مرحله بپرسید. پاسخ‌های قبلاً معلوم را دوباره نپرسید.
برای هر امکان سه گزینه «دارد»، «ندارد» و «نمی‌دانم» در نظر بگیرید: دارد = true، ندارد = false، نمی‌دانم = حذف فیلد از JSON. null، رشته "true"/"false" یا فیلد حدسی نفرستید.
ورودی‌های عددی را به عدد JSON تبدیل کنید؛ سن بنا به سال، مساحت به متر مربع، طبقه و تعدادها به عدد صحیح. district رشته "1"، "2"، "3" یا "4" است.
برای پارکینگ، اگر تعداد مشخص شد parkingSpaces را بفرستید و parking را با تعداد هماهنگ کنید. parkingSpaces=0 یعنی بدون پارکینگ؛ تعداد بر پرچم اولویت دارد.
برای زمین، سوال‌های امکانات بنا و مشاعات را رد کنید. landArea در محاسبه قیمت کل زمین بر area اولویت دارد.
کلید API را فقط در بک‌اند سایت نگه دارید و درخواست را با Authorization: Bearer <API_KEY> بفرستید؛ کلید را در کد مرورگر، فرم، URL یا بدنه JSON قرار ندهید.
قیمت‌ها به تومان هستند. بازه minimum..maximum، قیمت میانی middle و confidence را نمایش دهید. جزئیات بیشتر اطلاعات ورودی را کامل‌تر می‌کند؛ تضمین قیمت معامله یا اطمینان بالا نیست.
پاسخ 422 را از error.details بررسی و داده نامعتبر را اصلاح کنید. فیلد ناشناخته را نفرستید و نام‌های دقیق زیر را استفاده کنید.

### اطلاعات پایه
- latitude — عرض جغرافیایی: موقعیت ملک روی نقشه کجاست؟ مختصات WGS84 ارسال شود.
- longitude — طول جغرافیایی: طول جغرافیایی همان نقطه انتخاب‌شده روی نقشه چیست؟
- area — متراژ: مساحت ملک چند متر مربع است؟
- propertyType — نوع ملک: نوع ملک چیست؟ apartment = آپارتمان، house = خانه، land = زمین.
- district — منطقه: منطقه شهرداری ۱، ۲، ۳ یا ۴ است؟ این فیلد اختیاری است و سرور منطقه را از مختصات تعیین می‌کند.
- neighborhood — محله: نام محله چیست؟ نام محله جایگزین مختصات در تخمین اختصاصی ملک نمی‌شود.
- landArea — مساحت زمین: مساحت زمین چند متر مربع است؟ برای propertyType=land در قیمت کل بر area اولویت دارد.

### جزئیات بنا و واحد
- buildingAge — سن بنا: سن بنا چند سال است؟ برای نوساز عدد صفر بفرستید.
- bedrooms — تعداد خواب: واحد چند اتاق خواب دارد؟
- bathrooms — تعداد حمام و سرویس: چند حمام یا سرویس بهداشتی دارد؟
- floor — طبقه واحد: واحد در کدام طبقه است؟ همکف صفر، طبقات زیرزمین منفی.
- totalFloors — تعداد طبقات: ساختمان چند طبقه دارد؟ اطلاعات تکمیلی است؛ فعلاً ضریب مستقل قیمت ندارد.
- renovated — بازسازی: واحد بازسازی شده است؟

### امکانات واحد و ساختمان
- parking — پارکینگ: ملک پارکینگ دارد؟ اگر تعداد معلوم است، parkingSpaces را هم ارسال کنید.
- parkingSpaces — تعداد پارکینگ: چند جای پارک دارد؟ عدد صفر یعنی بدون پارکینگ؛ این فیلد بر parking اولویت دارد.
- elevator — آسانسور: ساختمان آسانسور دارد؟
- storage — انباری: واحد انباری دارد؟
- balcony — بالکن یا تراس: واحد بالکن یا تراس دارد؟
- centralCooling — تهویه مرکزی: سیستم تهویه مرکزی دارد؟
- premiumView — دید ممتاز: واحد دید ممتاز یا باز دارد؟

### مشاعات
- swimmingPool — استخر: ساختمان استخر قابل استفاده دارد؟
- saunaJacuzzi — سونا یا جکوزی: ساختمان سونا یا جکوزی دارد؟
- gym — باشگاه: باشگاه ورزشی در ساختمان وجود دارد؟
- lobby — لابی: ساختمان لابی دارد؟
- concierge — لابی‌من یا نگهبان: ساختمان لابی‌من یا نگهبان دارد؟
- roofGarden — روف‌گاردن: روف‌گاردن قابل استفاده دارد؟

### نمونه کامل (falseها در این مثال پاسخ صریح مالک هستند)
{
  "latitude": 35.769,
  "longitude": 51.453,
  "area": 100,
  "propertyType": "apartment",
  "district": "3",
  "neighborhood": "دروس",
  "buildingAge": 10,
  "bedrooms": 2,
  "bathrooms": 2,
  "floor": 3,
  "totalFloors": 6,
  "parking": true,
  "parkingSpaces": 1,
  "elevator": true,
  "storage": true,
  "renovated": false,
  "balcony": true,
  "centralCooling": true,
  "premiumView": false,
  "swimmingPool": true,
  "saunaJacuzzi": false,
  "gym": true,
  "lobby": true,
  "concierge": true,
  "roofGarden": false
}


## POST /api/v1/neighborhood-price — قیمت میانگین محله
Input uses a NAME, no coordinates. Required neighborhood: Persian string 2..80 chars.
Optional district: "1"|"2"|"3"|"4"; propertyType defaults to apartment; optional area returns estimated totals.
Example input: {"neighborhood":"دروس","district":"3","area":100}
The server normalizes Persian/Arabic letters and spacing, resolves catalog names/aliases and unambiguous spelling mistakes (including adjacent transpositions and up to two edits for longer names). اقدسیه، عقدسیه and عقدزسیه resolve to the same district-1 market area; spelling correction never substitutes نیاوران prices for اقدسیه prices. Shared names such as پاسداران require a district.
Catalog aliases that describe distinct market areas keep their exact sample name (e.g. الهیه); prices are never substituted from another neighborhood.
Equivalent source labels for the same neighborhood (e.g. امام زاده قاسم (نیاوران)) are matched automatically, and municipal neighborhoods without enough exact source-labeled samples may fall back to geo-verified observations strictly within that neighborhood's boundary in the same district.
Uses active observations dated within 180 days, excludes demo data and archived comparables, deduplicates linked calibration/comparable rows and removes 1.5*IQR outliers.
Requires at least 3 recent observations; otherwise returns INSUFFICIENT_DATA without making up a price.
Success data: neighborhood, canonicalNeighborhood, requestedNeighborhood, district, matchedBy, propertyType, currency="toman", pricePerM2={minimum,average,middle,maximum}, totalPrice=same fields or null, area, location, evidence, confidence, method, createdAt.
minimum=P10; maximum=P90; middle=median; average=arithmetic mean after outlier removal. This is an observed distribution, not a property's valuation interval.
location is the sample centroid with precision="sample-centroid", not the official neighborhood boundary.
evidence: sampleCount, excludedOutliers, verifiedCount, askingPriceCount, oldestDate, latestDate, maximumAgeDays=180. Converted Divar calibrations remain asking-price-derived evidence even if their listing was reviewed and the calibration row has a verified flag.
Confidence is sample-size based (3..7 low, 8..19 medium, >=20 high); inspect verifiedCount and askingPriceCount before treating it as transaction evidence.
Property features are heterogeneous: totalPrice is a neighborhood benchmark times area, not an individualized estimate.

Pricing uses the global method saved by the administrator: pricingMode="calibrated-model" (default) or "sample-based". Sample-based estimates use active same-type calibration observations within 2km, similarity/freshness weights and conservative relative feature adjustments, without the geographic baseline, tax or advertisement providers. No suitable observation returns 422 INSUFFICIENT_DATA. One observation can produce a low-confidence estimate. Converted listing observations remain asking-price-derived evidence.


## Agent research — asynchronous property pricing
This is an independent mode: pricingMode="agent-research". It does not call the calibrated model or reuse calibration prices.
The site's backend keeps its API key. This API does not collect phone numbers or send SMS. The site handles its own user journey and notifications.

### POST /api/v1/research-jobs
Headers: Authorization: Bearer <API_KEY>, Content-Type: application/json, Idempotency-Key: <8..128 ASCII letters/digits/_/->.
Body: {"property":{"latitude":35.769,"longitude":51.453,"area":100,"propertyType":"apartment","buildingAge":10,"parking":true},"clientReference":"your-site-request-id"}
property accepts the same details and amenities as EstimateInput. Omit unknown features. Current research types: apartment, house; land is explicitly rejected until its source parser is available. Coverage remains districts 1–4; district must match coordinates.
202 response: {"requestId":"...","data":{"id":"UUID","pricingMode":"agent-research","status":"queued","statusUrl":"/api/v1/research-jobs/UUID","reportUrl":"/api/v1/research-jobs/UUID/report",...}}
A repeated Idempotency-Key with the same validated input returns the existing job, including terminal state. A different input with the same key returns 409 IDEMPOTENCY_CONFLICT. Maximum 5 queued/running jobs per API key. To intentionally start a fresh investigation, use a new key.
503 AGENT_NOT_CONFIGURED means an administrator must enable a configured OpenAI-compatible text provider or combined mode; Jev alone cannot run the planning agent.

### GET /api/v1/research-jobs/{id}
Use Authorization, no request body. Poll about every 5–10 seconds. Keys can only read jobs created with that same key; another key receives 404.
Returns the same requestId/data envelope, with status, timestamps, property input, state (map address, search outcomes, evidence), events, usage and report (null while unfinished).
Statuses: queued, running, completed, insufficient_evidence, failed, cancelled. The last four are terminal. Stop polling at terminal status. failed/cancelled do not have a report. queued/running do not promise a completion time.
events contain seq, type, message, createdAt. Types include queued, started, location, search, accepted, rejected, source_error, retry and terminal status. The site can use started/completed/insufficient_evidence/failed events for its own notifications; deduplicate by (job id, seq). This service does not deliver callbacks or SMS.

### GET /api/v1/research-jobs/{id}/report
Use Authorization, no body. Returns 409 REPORT_NOT_READY until a completed or insufficient_evidence report exists.
The report is JSON for the site's report page, not a public unauthenticated URL. Render it from the site's backend; keep the key private.
Report: version, generatedAt, outcome, address, currency=toman, price={minimum,middle,maximum,average} or null, pricePerM2=same shape or null, confidence=low|medium, effectiveSampleSize, usedCount, narrative, method, parameters, samples, evidence, limitations.
Evidence preserves source URL, title, property details, askingPrice, sourceCategory, publishedAt, checkedAt, accepted, reason, addressQuote. checkedAt/observedAt are retrieval times, not publication dates. publicationPrecision=relative-upper-bound means publishedAt is a conservative approximate time derived from publicationText (for example one week ago is assessed at its upper age bound); display that approximation. source-timestamp means the source supplied an explicit timestamp. Unknown or older-than-14-day publication dates, rent/presale/exchange, unknown sale category, unverified street/neighborhood, >2x area mismatch, duplicate units and price outliers are excluded.
Map address is approximate street-level evidence. Municipal zones/districts are not neighborhoods; if no actual neighborhood and street can be resolved, the job fails before model research with an explicit map-source explanation. An alley is shown only if supported by map data; adjacency does not prove a building number or exact ad coordinates. The model may choose only source-grounded queries/tokens and can reject evidence but cannot bypass deterministic source guards.
Divar may automatically change the requested category for ambiguous street names. Search verifies the returned category and source result list before inspecting ads; wrong-category or unparseable responses are source errors. The agent can try mapped street-qualified variants such as خیابان + street. If source errors prevent collecting enough evidence, the job is failed rather than a claim of market insufficiency. Older terminal reports remain historical snapshots; use a new Idempotency-Key to start new research after a source-handling fix.
The autonomous loop observes search outcomes and chooses its next search/detail action. Each action is checkpointed; server restarts resume persisted jobs after an expiring lease. A crash can repeat the in-flight external call (at-least-once execution), so providers may bill an extra attempt.
No minimum sample requirement is bypassed: fewer than 3 independent valid ads, or effective sample size <2.5, returns insufficient_evidence with null prices. The site must display the evidence limitation, not substitute zero or a synchronous estimate.
All evidence is asking-price evidence. The interval and confidence are transparent heuristics, not a calibrated probability or guaranteed transaction value. Read method, parameters and limitations in each report.
Limits: 70 planning turns, 8 searches, 40 inspected listings, 100 model calls, 150000 reported input+output tokens. The token ceiling is checked between steps and can overshoot by one action. Unknown provider usage cannot enforce a precise token budget; the call/step caps still apply.
Usage: apiCalls (model+map+Divar attempts), modelCalls, inputTokens, outputTokens, unknownTokenCalls, estimatedCostUsd (null when unpriced/incomplete). usageLedger contains actual model, tool, duration, success and reported tokens for each completed/failed attempt; a hard process crash during an outstanding request may leave provider charges unknown. Unreported tokens are unknown, not zero. API polling calls are logged separately in the API dashboard.
Admin operations and report preview: /research. Administrator can cancel a queued/running job; a late result cannot overwrite cancellation.


## Errors
{ "requestId": "UUID", "error": { "code": "CODE", "message": "description", "details": OPTIONAL_OBJECT } }
401 UNAUTHORIZED; 429 RATE_LIMITED (Retry-After: 60); 415 JSON_REQUIRED; 413 BODY_TOO_LARGE; 400 INVALID_JSON;
422 VALIDATION_ERROR / OUTSIDE_COVERAGE / INSUFFICIENT_DATA; 404 UNKNOWN_NEIGHBORHOOD; 409 AMBIGUOUS_NEIGHBORHOOD; 500 INTERNAL_ERROR.
Unknown input fields are rejected. Do not repeatedly retry invalid/insufficient requests. Retry 429 after the header delay; retry temporary 500 sparingly.

## Supported catalog
District 1: اراج؛ ازگل؛ امامزاده قاسم؛ اوین؛ باغ فردوس؛ تجریش؛ جماران؛ چیذر؛ حصار بوعلی؛ حکمت؛ دارآباد؛ دربند؛ درکه؛ دزاشیب؛ زعفرانیه؛ سوهانک؛ شهرک دانشگاه؛ شهرک نفت؛ شهرک شهید محلاتی (aliases: شهرک محلاتی)؛ فرمانیه (aliases: کامرانیه شمالی، کامرانیه)؛ قیطریه؛ کاشانک؛ کوهسار؛ گلابدره؛ محمودیه (aliases: الهیه، فرشته)؛ نیاوران (aliases: اقدسیه)؛ ولنجک؛ گلها (aliases: شهرک گلها)؛ مینی‌سیتی (aliases: مینی سیتی)؛ هزارسنگ
District 2: پونک؛ تهران ویلا (aliases: تهران‌ویلا)؛ دریان نو (aliases: دریان‌نو، شادمهر)؛ سعادت آباد (aliases: سعادت‌آباد)؛ شهرآرا؛ شهرک غرب (aliases: شهرک قدس)؛ صادقیه (aliases: آریاشهر)؛ طرشت؛ فرحزاد؛ گیشا (aliases: کوی نصر)؛ شهرک آزمایش؛ ستارخان؛ مرزداران (aliases: شهرک ژاندارمری)؛ آسمان؛ بهرود؛ پرواز؛ دریا؛ سپهر؛ ایوانک؛ شریف (aliases: دانشگاه شریف)؛ توحید
District 3: آرارات؛ امانیه (aliases: جردن، آفریقا)؛ اختیاریه (aliases: دولت، دیباجی، رستم آباد)؛ پاسداران؛ دروس؛ داودیه (aliases: میرداماد)؛ زرگنده؛ سیدخندان (aliases: سید خندان)؛ قلهک؛ کاوسیه (aliases: ظفر)؛ ونک؛ ده ونک (aliases: ده‌ونک)؛ درب دوم؛ قبا
District 4: اوقاف؛ پاسداران؛ ضرابخانه (aliases: ضراب خانه)؛ تهرانپارس شرقی (aliases: تهران پارس شرقی)؛ تهرانپارس غربی (aliases: تهران پارس غربی)؛ حسین آباد (aliases: هروی)؛ مبارک آباد؛ حکیمیه؛ شمس آباد؛ مجیدیه (aliases: مجیدیه شمالی)؛ شمیران نو؛ علم و صنعت؛ قاسم آباد؛ قنات کوثر؛ کاظم آباد؛ کالاد؛ کوهسار؛ گلشن (aliases: خاک سفید)؛ لویزان؛ شیان؛ مجیدآباد؛ مهران؛ نارمک شمالی (aliases: نارمک)؛ اتحاد؛ استخر؛ تهرانپارس (aliases: تهران پارس)؛ جوادیه تهرانپارس (aliases: جوادیه تهران پارس)؛ کوهک؛ کوی نوبنیاد (aliases: نوبنیاد)

## curl examples
curl -X POST 'https://ai.bamelak.com/api/v1/neighborhood-price' -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{"neighborhood":"دروس","area":100}'
curl -X POST 'https://ai.bamelak.com/api/v1/estimate' -H 'Authorization: Bearer YOUR_API_KEY' -H 'Content-Type: application/json' -d '{"latitude":35.769,"longitude":51.453,"area":100,"propertyType":"apartment"}'