Developer APIs
Welcome to the National Farmer ID Registry (NFD) developer integration documents. Our simple APIs allow external clients and mobile integrations (Android/iOS) to log users in securely and generate smart, bilingual high-resolution PDF or JPEG farmer identification cards.
User Authentication API
Logs a registered farmer in using their mobile number and password credentials. Starts a secure PHP session and returns the session token identifier alongside the user profile details.
Request Parameters
Accepts both standard JSON payloads and form POST parameters.
| Parameter | Type | Status | Description |
|---|---|---|---|
| mobile | string | Required | The farmer's registered 10-digit mobile number. |
| password | string | Required | The plain-text account password. |
{
"mobile": "9876543210",
"password": "farmer_secure_pass123"
}
{
"success": true,
"message": "Login successful",
"session_id": "o12k4m8n3b5v9c1x7z0l3k4j5h",
"user": {
"id": 48,
"fullname": "Ramesh Kumar",
"mobile": "9876543210",
"state": "Uttar Pradesh",
"wallet_balance": 250.00
}
}
{
"success": false,
"error": "Invalid mobile number or password."
}
Card Generation API
Generates high-resolution smart card graphics (front and back templates). Draws user details, photo, and dynamic QR Code in both Devanagari (local state languages) and English. If fetching a new card, it accesses the external portal and deducts balance from the user's wallet. Otherwise, it retrieves the cached response for free if a `download_id` is supplied.
Cookie: PHPSESSID=your_session_id.
Request Parameters
Accepts JSON payload or form variables. State Name and Aadhaar are required only when doing a fresh fetch (i.e. without download_id).
| Parameter | Type | Status | Description |
|---|---|---|---|
| download_id | integer | Optional | Retrieve an existing card download record from history for free (No balance deducted). |
| state_name | string | Optional* | State Farmer registry to target (e.g. "Uttar Pradesh", "Maharashtra"). Required for new fetches. |
| aadhar | string | Optional* | 12-digit Aadhaar Card number of the farmer. Required for new fetches. |
{
"state_name": "Uttar Pradesh",
"aadhar": "123456789012"
}
{
"download_id": 124
}
{
"success": true,
"farmerID": "UP-FARM-998811",
"front_card_base64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...",
"back_card_base64": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQ...",
"farmer_data": {
"farmerID": "UP-FARM-998811",
"name_en": "Ramesh Kumar",
"name_local": "रमेश कुमार",
"gender": "MALE",
"dob": "15/08/1984",
"mobile": "9876543210",
"aadhar": "XXXX-XXXX-1234",
"state": "Uttar Pradesh",
"address": "Village Kalan, District Meerut, Uttar Pradesh",
"land_details": [
{
"district": "Meerut",
"subDist": "Meerut",
"village": "Kalan",
"sno": "123",
"area": "1.250",
"khata": "123",
"khasra": "456"
}
]
}
}
{
"success": false,
"error": "Unauthorized. Please log in first."
}
Verify Card Details API
Retrieves the exact raw API verification response of the farmer ID card directly from the external registry. If it is a first-time fetch, it charges the user's wallet. If it's a re-download/lookup, the balance is not deducted.
Cookie: PHPSESSID=your_session_id.
Request Parameters
Accepts both standard form variables and JSON payload parameters.
| Parameter | Type | Status | Description |
|---|---|---|---|
| state_name | string | Required | State Farmer registry to target (e.g. "Uttar Pradesh", "Maharashtra"). |
| aadhar | string | Required | 12-digit Aadhaar Card number of the farmer. |
{
"state_name": "Uttar Pradesh",
"aadhar": "123456789012"
}
{
"data": {
"farmerDetails": {
"aadhaarNameMatchScore": 98,
"aadharVerified": false,
"centralId": "72307033213",
"farmerDob": "1976-12-31T18:30:00.000Z",
"farmerNameEn": "Parmar Amarsinh Shakrabhai",
"farmerNameLocal": "પરમાર અમરસિંહ શકરાભાઇ",
"farmerMobileNumber": "9723242847",
"farmerAadharMask": "**** **** 4003",
"farmerExtendedRegistry": {
"ferFarmerPhotograph": "/9j/4AAQSkZJRgAB..."
}
},
"farmerLandOwnerShips": [
{
"extentAssignedAreaInHectare": 0.2627,
"khataNumber": "486",
"surveyNumber": "708",
"ownerNamePerRor": "અમરસિંહ શકરાભાઈ ૫રમાર"
}
]
}
}
{
"success": false,
"error": "Unauthorized. Please log in first."
}