API

API Documentation

Programmatic access to India's PIN code and location data

Base URL

GET https://irphan.com/api/

All API responses are in JSON format. No authentication is required for public endpoints.

Search API

Search Locations & PIN Codes

GET /api/search?q={query}

Searches across PIN codes, states, districts, cities, and areas.

Example Request
GET /api/search?q=110001
Example Response
{
  "query": "110001",
  "result_count": 1,
  "result_type": "exact_pin",
  "action": "redirect",
  "redirect_url": "/pincode/110001",
  "results": [
    {
      "type": "pincode",
      "title": "110001",
      "slug": "110001",
      "url": "/pincode/110001",
      "subtitle": "New Delhi, Delhi"
    }
  ]
}

Autocomplete Suggestions

GET /api/search/suggest?q={query}

Returns up to 10 autocomplete suggestions for the given query. Used by the search box dropdown.

Example Request
GET /api/search/suggest?q=Pune
Example Response
{
  "query": "Pune",
  "suggestions": [
    {
      "type": "city",
      "title": "Pune",
      "subtitle": "Maharashtra",
      "url": "/city/pune",
      "icon": "🏙️"
    }
  ]
}

Homepage Statistics

GET /api/public/stats

Returns live counts of states, districts, cities, areas, and PIN codes in the database.

Example Response
{
  "states": 35,
  "districts": 655,
  "cities": 8913,
  "areas": 79175,
  "pin_codes": 79175,
  "mappings": 152340
}

Rate Limits

To ensure fair usage, the following rate limits apply:

  • 🔍 Search API: 60 requests per minute per IP
  • 💡 Suggest API: 120 requests per minute per IP

Rate limit headers are included in every response:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1718010600

Click Tracking (POST)

POST /api/search/click

Used internally to track which search results are clicked. Body parameters:

  • query — The search query string
  • url — The URL that was clicked