Digital Mandi Partner API v1 https://partners.digitalmandi.online Website →

Partner API

Read-only access to Digital Mandi's crop, feed mill and sugar mill rates from across Pakistan, for integration into your own products.

Base URLhttps://partners.digitalmandi.online
FormatJSON over HTTPS. Only GET requests are used.
AuthenticationAPI key in the X-API-Key header
PricesPakistani Rupees (PKR). Crop rates are PKR per 40 kg (maund).
Time zoneDates and quota resets use Asia/Karachi (PKT, UTC+5).

Getting access

API keys are issued by the Digital Mandi team.

Each key has:

  • a set of endpoints it may call (calling any other returns 403 endpoint_not_allowed),
  • a per-minute rate limit and, usually, a daily and/or monthly quota,
  • optionally, an IP allowlist and an expiry date.

Call GET /v1/me any time to see your key's current settings and usage.

Your key is shown to you only once. Digital Mandi stores only a fingerprint of it and cannot recover it. If it is lost or leaked, ask for a new one. The old key stops working the moment a new one is issued.

Authentication

Send your key with every request in the X-API-Key header. Authorization: Bearer <key> is also accepted. Keys start with dm_live_.

curl -H "X-API-Key: dm_live_your_key_here" \
     "https://partners.digitalmandi.online/v1/crop-rates/latest?crop_id=1"
$ch = curl_init('https://partners.digitalmandi.online/v1/crop-rates/latest?crop_id=1');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['X-API-Key: ' . getenv('DIGITAL_MANDI_API_KEY')],
    CURLOPT_TIMEOUT => 15,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

$json = json_decode($body, true);
if ($status !== 200) {
    throw new RuntimeException($json['error']['code'] . ': ' . $json['error']['message']);
}
foreach ($json['data'] as $rate) {
    echo $rate['crop_type']['name'], ' @ ', $rate['city']['name'], ': ',
         $rate['min_price'], ' - ', $rate['max_price'], PHP_EOL;
}
const res = await fetch('https://partners.digitalmandi.online/v1/crop-rates/latest?crop_id=1', {
  headers: { 'X-API-Key': process.env.DIGITAL_MANDI_API_KEY },
});
const json = await res.json();
if (!res.ok) throw new Error(`${json.error.code}: ${json.error.message}`);

for (const rate of json.data) {
  console.log(rate.crop_type.name, rate.city.name, rate.min_price, rate.max_price);
}
import os, requests

res = requests.get(
    "https://partners.digitalmandi.online/v1/crop-rates/latest",
    params={"crop_id": 1},
    headers={"X-API-Key": os.environ["DIGITAL_MANDI_API_KEY"]},
    timeout=15,
)
json = res.json()
if not res.ok:
    raise RuntimeError(f"{json['error']['code']}: {json['error']['message']}")

for rate in json["data"]:
    print(rate["crop_type"]["name"], rate["city"]["name"], rate["min_price"], rate["max_price"])
Use your key only from your servers. Never put it in a mobile app, website JavaScript, or a public repository. Anyone who has the key can use your quota. The API does not send CORS headers, so browsers cannot call it directly.

Responses & data

Successful responses are 200 OK with a JSON object. The result is in data (a list, or an object for /v1/me), and meta holds the row count and context such as currency and unit.

{
  "data": [ ... ],
  "meta": { "count": 42, "currency": "PKR", "unit": "PKR per 40 kg (maund)" }
}
  • Names are given in English (name) and Urdu (name_ur).
  • min_price / max_price are the lowest and highest price reported for that day. previous_min_price / previous_max_price are from the previous reported day, so you can show the change.
  • Dates are YYYY-MM-DD. Timestamps are ISO 8601 with offset.
  • Mandi rates are reported throughout the day, mostly in the morning. Responses can be up to 5 minutes behind the latest update.
  • Fields may be added to responses in v1 at any time. Make your parser ignore fields it does not know.

Rate limits & quotas

Every successful response includes headers that show where you stand:

HeaderMeaning
X-RateLimit-LimitRequests allowed per minute for your key.
X-RateLimit-RemainingRequests left in the current minute.
X-Quota-Daily-LimitRequests allowed per day (only if your key has a daily quota).
X-Quota-Daily-RemainingRequests left today.

When a limit is reached the API returns 429 Too Many Requests with a Retry-After header (seconds). Wait that long before retrying. Daily quotas reset at midnight PKT and monthly quotas on the 1st of the month. Requests rejected by authentication or limits (401, 403 and 429 responses) do not count towards your quota. All other requests do, including 422 validation errors.

Errors

Errors use the matching HTTP status and a body like this:

{
  "error": {
    "code": "endpoint_not_allowed",
    "message": "This API key does not have access to this endpoint."
  }
}

Validation errors (422) also include fields, with the messages for each invalid parameter. Branch on code, not on the message text.

StatuscodeWhat to do
401missing_api_keySend the X-API-Key header.
401invalid_api_keyCheck the key. It may have been replaced by a new one.
403key_suspendedYour access is paused. Contact Digital Mandi.
403key_expiredYour key's validity period has ended. Contact Digital Mandi.
403ip_not_allowedCall from an allowlisted server IP, or ask for your IP to be added.
403endpoint_not_allowedYour key cannot use this endpoint. Ask for access if you need it.
404not_foundUnknown URL, or an id (e.g. crop_type_id) that does not exist.
422validation_failedFix the parameters listed in fields.
429rate_limitedPer-minute limit reached. Wait for Retry-After.
429daily_quota_exceededDaily quota used up. It resets at midnight PKT.
429monthly_quota_exceededMonthly quota used up. It resets on the 1st.
429too_many_failed_attemptsToo many requests with an invalid key from your IP. Fix the key and wait a minute.
5xxserver_error / unavailableOur problem. Retry with exponential backoff (e.g. 2s, 4s, 8s).

Best practices

  • Cache on your side. Rates change a few times a day, so polling every 5 to 15 minutes is plenty. Cache /v1/crops and /v1/cities for a day.
  • Use filters (crop_id, city_id) instead of downloading everything and filtering locally.
  • Honour Retry-After on 429s, and back off on 5xx errors. Do not retry 4xx errors other than 429 without changing the request.
  • Store the key in an environment variable or secret manager, not in code.
  • Show attribution to Digital Mandi wherever the rates are displayed, unless your agreement says otherwise.
GET /v1/me Available to every key

Your key and usage

Details of the key making the request: its status, which endpoints it can call, its limits, and how much of its quota is used. Every valid key can call this, and calls to it count towards the quota like any other request.

Query parameters

None.

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/me"

Example response

{
    "data": {
        "name": "Acme Agri Integration",
        "company": "Acme Pvt Ltd",
        "key_prefix": "dm_live_a1b2c3",
        "status": "active",
        "expires_at": null,
        "allowed_endpoints": [
            "crops",
            "cities",
            "crop-rates.latest"
        ],
        "limits": {
            "requests_per_minute": 60,
            "daily_quota": 5000,
            "monthly_quota": null
        },
        "usage": {
            "today": 132,
            "this_month": 2841
        }
    }
}
GET /v1/crops Access: crops

List crops and crop types

All active crops with their types (varieties). Use the type ids as crop_type_id in the rate endpoints. This list changes rarely, so cache it on your side for a day.

Query parameters

None.

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/crops"

Example response

{
    "data": [
        {
            "id": 1,
            "name": "Wheat",
            "name_ur": "گندم",
            "types": [
                {
                    "id": 4,
                    "name": "Wheat (New)",
                    "name_ur": "گندم نئی"
                }
            ]
        }
    ],
    "meta": {
        "count": 1
    }
}
GET /v1/cities Access: cities

List cities (mandis)

All cities (mandis) that rates are reported for. Use the ids as city_id. Cache this on your side for a day.

Query parameters

None.

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/cities"

Example response

{
    "data": [
        {
            "id": 12,
            "name": "Okara",
            "name_ur": "اوکاڑہ"
        }
    ],
    "meta": {
        "count": 1
    }
}
GET /v1/crop-rates/latest Access: crop-rates.latest

Latest crop rates per city

Current mandi rates: one row per crop type per city. For each crop type, the rows are from the most recent day that type had any rate reported (filtered by your city_id if given), so different crop types can have different rate_date values. Pass date to get a specific day instead.

Query parameters

NameTypeRequiredDescription
crop_idintegerNoOnly types of this crop.
crop_type_idintegerNoOnly this crop type.
city_idintegerNoOnly this city. The latest day is then the latest day for this city.
dateYYYY-MM-DDNoRates for this exact day instead of the latest day.

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/crop-rates/latest?crop_id=1&city_id=12"

Example response

{
    "data": [
        {
            "rate_date": "2026-11-23",
            "crop": {
                "id": 1,
                "name": "Wheat",
                "name_ur": "گندم"
            },
            "crop_type": {
                "id": 4,
                "name": "Wheat (New)",
                "name_ur": "گندم نئی"
            },
            "city": {
                "id": 12,
                "name": "Okara",
                "name_ur": "اوکاڑہ"
            },
            "min_price": 3850,
            "max_price": 4000,
            "previous_min_price": 3800,
            "previous_max_price": 3950
        }
    ],
    "meta": {
        "count": 1,
        "currency": "PKR",
        "unit": "PKR per 40 kg (maund)"
    }
}
GET /v1/crop-rates/summary Access: crop-rates.summary

Latest national min/max per crop type

One row per crop type with the nationwide lowest and highest price on that type's most recent market day, and how many cities reported. This is the headline rate shown in the Digital Mandi app.

Query parameters

NameTypeRequiredDescription
crop_idintegerNoOnly types of this crop.

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/crop-rates/summary?crop_id=1"

Example response

{
    "data": [
        {
            "rate_date": "2026-11-23",
            "crop": {
                "id": 1,
                "name": "Wheat",
                "name_ur": "گندم"
            },
            "crop_type": {
                "id": 4,
                "name": "Wheat (New)",
                "name_ur": "گندم نئی"
            },
            "min_price": 3700,
            "max_price": 4100,
            "previous_min_price": 3650,
            "previous_max_price": 4050,
            "cities_reported": 18
        }
    ],
    "meta": {
        "count": 1,
        "currency": "PKR",
        "unit": "PKR per 40 kg (maund)"
    }
}
GET /v1/crop-rates/history Access: crop-rates.history

Daily rate history for a crop type

Daily lowest and highest price for one crop type over a date range, for one city or across all cities. Days with no reported rate are left out. Defaults to the last 30 days.

The range may cover at most 366 days per request.

Query parameters

NameTypeRequiredDescription
crop_type_idintegerYesThe crop type.
city_idintegerNoOne city. Leave out for all cities combined.
fromYYYY-MM-DDNoFirst day (default: 29 days before "to").
toYYYY-MM-DDNoLast day (default: today).

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/crop-rates/history?crop_type_id=4&from=2026-11-01&to=2026-11-23"

Example response

{
    "data": [
        {
            "rate_date": "2026-11-22",
            "min_price": 3650,
            "max_price": 4050,
            "cities_reported": 16
        },
        {
            "rate_date": "2026-11-23",
            "min_price": 3700,
            "max_price": 4100,
            "cities_reported": 18
        }
    ],
    "meta": {
        "count": 2,
        "crop": {
            "id": 1,
            "name": "Wheat",
            "name_ur": "گندم"
        },
        "crop_type": {
            "id": 4,
            "name": "Wheat (New)",
            "name_ur": "گندم نئی"
        },
        "city": null,
        "from": "2026-11-01",
        "to": "2026-11-23",
        "currency": "PKR",
        "unit": "PKR per 40 kg (maund)"
    }
}
GET /v1/feed-mill-rates Access: feed-mill-rates

Latest feed mill rates

The latest rate posted by each active feed mill.

Query parameters

NameTypeRequiredDescription
city_idintegerNoOnly mills in this city.

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/feed-mill-rates"

Example response

{
    "data": [
        {
            "id": 3,
            "name": "Example Mills",
            "name_ur": "مثال ملز",
            "city": {
                "id": 7,
                "name": "Faisalabad",
                "name_ur": "فیصل آباد"
            },
            "min_price": 4100,
            "max_price": 4250,
            "previous_min_price": 4050,
            "previous_max_price": 4200,
            "updated_at": "2026-11-23T10:15:00+05:00"
        }
    ],
    "meta": {
        "count": 1,
        "currency": "PKR"
    }
}
GET /v1/sugar-mill-rates Access: sugar-mill-rates

Latest sugar mill rates

The latest rate posted by each active sugar mill.

Query parameters

NameTypeRequiredDescription
city_idintegerNoOnly mills in this city.

Example request

curl -H "X-API-Key: $DIGITAL_MANDI_API_KEY" "https://partners.digitalmandi.online/v1/sugar-mill-rates"

Example response

{
    "data": [
        {
            "id": 3,
            "name": "Example Sugar Mills",
            "name_ur": "مثال ملز",
            "city": {
                "id": 7,
                "name": "Faisalabad",
                "name_ur": "فیصل آباد"
            },
            "min_price": 4100,
            "max_price": 4250,
            "previous_min_price": 4050,
            "previous_max_price": 4200,
            "updated_at": "2026-11-23T10:15:00+05:00"
        }
    ],
    "meta": {
        "count": 1,
        "currency": "PKR"
    }
}

Versioning & changes

The version is part of the URL (/v1). Within v1 we only make backward-compatible changes: new endpoints, new optional parameters and new response fields. Anything that would break existing integrations, such as removing or renaming a field or changing its type, will ship as /v2, and v1 will keep running alongside it for a notice period.