# Divar — Wrapped API

> **You are on:** `https://api.beta.paywithlocus.com/api` | [llms.txt](https://beta.paywithlocus.com/llms.txt) | [docs](https://docs.paywithlocus.com)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API | Docs |
> |---|---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com | docs.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com | docs.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.paywithlocus.com | docs.paywithlocus.com |
>
> If the API URL above doesn't match your expected environment, re-fetch this file from the correct domain.

> Search for classified listings across Iran's largest marketplace by city, category, and keywords to find products, services, and deals. Access detailed information about specific posts including pricing, descriptions, and seller details to make informed purchasing decisions.

**Category:** Marketplaces | **Website:** [www.divar.ir/](https://www.divar.ir/) | **Docs:** [parse.bot/marketplace/95b1c84a-73c9-4fd2-8312-196f87b9a591/divar-ir-api](https://parse.bot/marketplace/95b1c84a-73c9-4fd2-8312-196f87b9a591/divar-ir-api)

Pay-per-use API proxy for Locus Pro. Each call burns credits from your workspace balance.

## Access

**Base URL:** `https://api.beta.paywithlocus.com/api/wrapped/credits/divar/`
**Auth:** `Authorization: Bearer <LOCUS_CREDITS_SECRET_KEY>` (an `lcr_` secret key or a scoped `lcac_` agent credential)
**Required header:** `Idempotency-Key: <fresh UUID per call>`. A retry with the same key replays the stored result without a new charge.
**Response:** the provider response after any endpoint-specific normalization. `X-Locus-Credits-Charged` carries the charge and `X-Locus-Credits-Balance` the remaining balance. Insufficient credits return `402` before the provider is called.
**Pricing:** estimated costs below are USD. Locus debits the credit equivalent at your workspace rate.

Full call contract: https://docs.paywithlocus.com/api-reference/introduction

> Using a Pay With Locus wallet key (`claw_` prefix)? Wallet routes are documented separately: https://docs.paywithlocus.com/wrapped-apis/for-agents

## Endpoints

### Get post details

Retrieve full details of a single Divar listing by its token. Returns structured data including title, description, category breadcrumb, item properties (condition, price, type-specific attributes), images with thumbnails, and geographic location coordinates. The token is obtained from search_posts results.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `token` | string | Yes | The unique post token identifier, obtained from search_posts results (e.g. 'garQy9Dl'). |

```bash
curl -X POST https://api.beta.paywithlocus.com/api/wrapped/credits/divar/get-post-details \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"token":"<string>"}'
```

### Search posts

Search and list classified ad posts on Divar. Accepts a city slug, optional free-text query, and category filter. Returns a list of post summaries including title, price text, location, and image info. Results are sorted by newest first. Each post carries a token usable with get_post_details for the full listing.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `category` | string | No | Category slug to filter results. Use ROOT for all categories. Examples of category slugs: personal, clothing-and-shoes, clothing, vehicles, real-estate, digital-goods, home-kitchen, services, entertainment, industrial, jobs. |
| `city` | string | No | City slug for filtering posts. Accepted values: tehran, mashhad, karaj, shiraz, isfahan, ahvaz, tabriz, kermanshah, qom, rasht. Alternatively, pass a numeric city ID directly. |
| `limit` | integer | No | Maximum number of posts to return from the search results. |
| `query` | string | No | Free-text search query to match against post titles and descriptions. Empty string returns all recent posts. |

```bash
curl -X POST https://api.beta.paywithlocus.com/api/wrapped/credits/divar/search-posts \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"category":"<string>","city":"<string>","limit":"<integer>","query":"<string>"}'
```

## Next steps

- [All wrapped API providers](https://beta.paywithlocus.com/wapi/index.md): pick another provider.
- [Find and call tools](https://beta.paywithlocus.com/agent/tools.md): price ceilings, async results, and errors.
- [Credits and billing](https://beta.paywithlocus.com/agent/billing.md): what a call costs and how to add credits.
- [Agent docs index](https://beta.paywithlocus.com/agent/index.md): every Locus agent page.