Location Master API
High-performance REST API for Indian location data — States, Cities, Areas, and Pincodes. Built with Core PHP, MySQL, and caching for CRM, mobile apps, websites, and third-party integrations.
GET Only
JSON / UTF-8
Cache 24h
CORS Enabled
PHP 8+
Base URL
https://pincode.devindia.in/api/location.php
Append query parameters to this URL for all API requests.
ProtocolHTTP / HTTPS
MethodGET only
FormatJSON (UTF-8)
AuthOptional JWT
Response Format
Success (HTTP 200)
{
"status": true,
"message": "Success",
"count": 1,
"data": []
}
Error
{
"status": false,
"message": "Error Message"
}
HTTP Status Codes
| Code | Meaning |
|---|---|
200 | Success |
400 | Invalid or missing parameters |
401 | Unauthorized (JWT enabled) |
404 | Record not found |
405 | Method not allowed |
500 | Internal server error |
Endpoints
GET
action=states
Returns a list of all states.
https://pincode.devindia.in/api/location.php?action=states
Try it
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be states |
GET
action=cities&state_id=1
Returns all cities for a given state ID.
https://pincode.devindia.in/api/location.php?action=cities&state_id=1
Try it
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be cities |
state_id | integer | Yes | Valid state ID |
{
"status": true,
"message": "Success",
"count": 1,
"data": [{ "city_id": "10", "city_name": "Varanasi" }]
}
Cache: LOC:CITY_{state_id}
GET
action=areas&city_id=10
Returns all areas with pincodes for a given city ID.
https://pincode.devindia.in/api/location.php?action=areas&city_id=10
Try it
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be areas |
city_id | integer | Yes | Valid city ID |
GET
action=pincode&pin=221005
Returns complete location details for a 6-digit Indian pincode.
https://pincode.devindia.in/api/location.php?action=pincode&pin=221005
Try it
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be pincode |
pin | string | Yes | 6-digit pincode |
{
"data": [{
"state_id": "1", "state_name": "Uttar Pradesh",
"city_id": "10", "city_name": "Varanasi",
"area_id": "100", "area_name": "Sigra",
"pincode": "221005"
}]
}
Cache: LOC:PIN_{pincode}
GET
action=search&{id_param}
Lookup a single record by ID (not by name). Provide exactly one ID parameter per request.
Search State by ID
https://pincode.devindia.in/api/location.php?action=search&state_id=1
Try it
Search City by ID
https://pincode.devindia.in/api/location.php?action=search&city_id=10
Try it
Search Area by ID
https://pincode.devindia.in/api/location.php?action=search&area_id=100
Try it
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | Must be search |
state_id | integer | One of three | Search by state ID |
city_id | integer | One of three | Search by city ID |
area_id | integer | One of three | Search by area ID |