API Reference

Complete reference for the Rasta Mapen Location API. All service endpoints require a valid API key via the x-api-key header.

GeocodingPlacesAutocomplete

API Info

Base URL

https://rasta-mapen-server.vercel.app/api/v1

Authentication

Header: x-api-key: YOUR_KEY

Response Format

JSON (UTF-8)

Rate Limit

500 req/day on Free plan

Quick Start

1

Get your API Key

Create an account and generate an API key from your dashboard.

2

Make your first request

Call any endpoint with your API key in the x-api-key header.

3

Get structured JSON

Every response includes success, data, and optional meta pagination.

Example Request

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/geocode/reverse?lat=23.8103&lon=90.4125" \
  -H "x-api-key: YOUR_API_KEY"

Response

{
  "success": true,
  "data": {
    "coordinates": { "lat": 23.8103, "lon": 90.4125 },
    "division": {
      "name": "Dhaka",
      "coordinates": { "type": "Point", "lat": 23.685, "lon": 90.3563 }
    },
    "district": {
      "name": "Dhaka",
      "coordinates": { "type": "Point", "lat": 23.81, "lon": 90.41 }
    },
    "thana": {
      "name": "Dhanmondi",
      "coordinates": { "type": "Point", "lat": 23.75, "lon": 90.37 }
    },
    "address": "Dhanmondi, Dhaka Sadar, Dhaka, Dhaka Division"
  }
}

Authentication

All service endpoints require a valid API key. You can pass it via request header or query parameter.

MethodExample
Headerx-api-key: rm_live_xxx
Query?api_key=rm_live_xxx

Base URL

https://rasta-mapen-server.vercel.app/api/v1

Auth Examples

# Via header
curl -H "x-api-key: rm_live_xxx" \
  "https://rasta-mapen-server.vercel.app/api/v1/divisions"

# Via query parameter
curl "https://rasta-mapen-server.vercel.app/api/v1/divisions?api_key=rm_live_xxx"
Try it live

Interactive reverse geocoding

Click anywhere on the map below — we'll call /geocode/reverse and show you the resolved address hierarchy in real time.

Map tiles are served free by OpenStreetMap contributors.

Divisions

2 endpoints
GET/api/v1/divisions
API Key

Get all divisions (paginated)

ParamInTypeReqDescription
pagequerynumbernoPage number (default 1)
limitquerynumbernoPer page (max 50, default 20)

Response: Array of divisions + meta pagination

GET/api/v1/divisions/:id
API Key

Get division by MongoDB ObjectId

ParamInTypeReqDescription
idpathstringyesMongoDB ObjectId

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/divisions?limit=8" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    {
      "name": "Dhaka",
      "coordinates": {
        "type": "Point",
        "lat": 23.685,
        "lon": 90.3563
      }
    },
    {
      "name": "Chittagong",
      "coordinates": {
        "type": "Point",
        "lat": 22.3569,
        "lon": 91.7832
      }
    }
  ]
}

Districts

4 endpoints
GET/api/v1/districts
API Key

Get all districts (paginated)

ParamInTypeReqDescription
pagequerynumbernoPage number
limitquerynumbernoPer page (max 50)
GET/api/v1/districts/:id
API Key

Get district by ID

GET/api/v1/districts/division/:name
API Key

Get districts by division name

ParamInTypeReqDescription
namepathstringyesDivision name (e.g. Dhaka)
GET/api/v1/districts/division-id/:divisionId
API Key

Get districts by division ID

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/districts/division/Dhaka" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    {
      "name": "Dhaka",
      "coordinates": {
        "type": "Point",
        "lat": 23.81,
        "lon": 90.41
      }
    },
    {
      "name": "Gazipur",
      "coordinates": {
        "type": "Point",
        "lat": 24,
        "lon": 90.43
      }
    }
  ]
}

Sub-Districts

4 endpoints
GET/api/v1/sub-districts
API Key

Get all sub-districts (paginated)

GET/api/v1/sub-districts/:id
API Key

Get sub-district by ID

GET/api/v1/sub-districts/district/:name
API Key

Get sub-districts by district name

GET/api/v1/sub-districts/division/:name
API Key

Get sub-districts by division name

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/sub-districts?limit=10" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    {
      "name": "Dhaka Sadar",
      "coordinates": {
        "type": "Point",
        "lat": 23.7,
        "lon": 90.37
      }
    },
    {
      "name": "Gazipur Sadar",
      "coordinates": {
        "type": "Point",
        "lat": 24,
        "lon": 90.43
      }
    }
  ]
}

Thanas

5 endpoints
GET/api/v1/thanas
API Key

Get all thanas (paginated)

GET/api/v1/thanas/:id
API Key

Get thana by ID

GET/api/v1/thanas/sub-district/:name
API Key

Get thanas by sub-district name

GET/api/v1/thanas/district/:name
API Key

Get thanas by district name

GET/api/v1/thanas/division/:name
API Key

Get thanas by division name

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/thanas/district/Dhaka" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    {
      "name": "Dhanmondi",
      "coordinates": {
        "type": "Point",
        "lat": 23.75,
        "lon": 90.37
      }
    },
    {
      "name": "Gulshan",
      "coordinates": {
        "type": "Point",
        "lat": 23.79,
        "lon": 90.41
      }
    }
  ]
}

Unions

6 endpoints
GET/api/v1/unions
API Key

Get all unions (paginated)

GET/api/v1/unions/:id
API Key

Get union by ID

GET/api/v1/unions/sub-district/:name
API Key

Get unions by sub-district name

GET/api/v1/unions/thana/:name
API Key

Get unions by thana name

GET/api/v1/unions/district/:name
API Key

Get unions by district name

GET/api/v1/unions/division/:name
API Key

Get unions by division name

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/unions?limit=10" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    {
      "name": "Mashka",
      "coordinates": {
        "type": "Point",
        "lat": 24.667,
        "lon": 90.8
      }
    },
    {
      "name": "Baliadi",
      "coordinates": {
        "type": "Point",
        "lat": 24.1,
        "lon": 90.25
      }
    }
  ]
}

Places

7 endpoints
GET/api/v1/places
API Key

Get all places (paginated, filterable)

ParamInTypeReqDescription
pagequerynumbernoPage number
limitquerynumbernoPer page (max 50)
typequerystringnoFilter by place type (e.g. restaurant)
districtquerystringnoFilter by district name
GET/api/v1/places/lookup
API Key

Smart lookup: find the place at lat/lon from cache, or fetch from Google Places and store it for next time.

ParamInTypeReqDescription
latquerynumberyesLatitude
lonquerynumberyesLongitude
radiusquerynumbernoMatch radius in meters (default 60)

Response: { place, source: "db" | "google" | "none", isNew: boolean }

GET/api/v1/places/search
API Key

Search places by name

ParamInTypeReqDescription
qquerystringyesSearch query (min 2 chars)
limitquerynumbernoMax results (default 10)
GET/api/v1/places/nearby
API Key

Find nearby places using geospatial query

ParamInTypeReqDescription
latquerynumberyesLatitude
lngquerynumberyesLongitude
radiusquerynumbernoRadius in meters (default 1000)
typequerystringnoFilter by place type
GET/api/v1/places/district/:name
API Key

Get places by district name

GET/api/v1/places/type/:type
API Key

Get places by type

GET/api/v1/places/:id
API Key

Get place by ID

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/places/search?q=restaurant&limit=5" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    {
      "name": "Star Kabab",
      "coordinates": {
        "lat": 23.75,
        "lon": 90.38
      }
    },
    {
      "name": "Pizza Hut",
      "coordinates": {
        "lat": 23.79,
        "lon": 90.41
      }
    }
  ]
}

Geocoding

3 endpoints
GET/api/v1/geocode/reverse
API Key

Reverse geocode — coordinates to full address hierarchy

ParamInTypeReqDescription
latquerynumberyesLatitude
lonquerynumberyesLongitude

Response: Division → District → Sub-district → Thana → Union + nearby places + formatted address

GET/api/v1/geocode/search
API Key

Forward geocode — search all entities by name

ParamInTypeReqDescription
qquerystringyesSearch query (min 2 chars)
limitquerynumbernoMax results (default 10)

Response: Array of results with type, name, coordinates

GET/api/v1/geocode/autocomplete
API Key

Fast prefix search for real-time typing

ParamInTypeReqDescription
qquerystringyesSearch prefix
limitquerynumbernoMax results (default 8)

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/geocode/reverse?lat=23.8103&lon=90.4125" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "message": "Reverse geocoding successful",
  "data": {
    "coordinates": {
      "lat": 23.8103,
      "lon": 90.4125
    },
    "division": {
      "name": "Dhaka",
      "coordinates": {
        "type": "Point",
        "lat": 23.685,
        "lon": 90.3563
      }
    },
    "district": {
      "name": "Dhaka",
      "coordinates": {
        "type": "Point",
        "lat": 23.81,
        "lon": 90.41
      }
    },
    "sub_district": {
      "name": "Dhaka Sadar",
      "coordinates": {
        "type": "Point",
        "lat": 23.7,
        "lon": 90.37
      }
    },
    "thana": {
      "name": "Dhanmondi",
      "coordinates": {
        "type": "Point",
        "lat": 23.75,
        "lon": 90.37
      }
    },
    "union": null,
    "nearby_places": [
      {
        "name": "Dhanmondi Lake",
        "coordinates": {
          "lat": 23.7465,
          "lon": 90.3736
        }
      }
    ],
    "address": "Dhanmondi, Dhaka Sadar, Dhaka, Dhaka Division"
  }
}

Ward Zones

3 endpoints
GET/api/v1/ward-zones
API Key

Get all ward zones (paginated)

GET/api/v1/ward-zones/city/:city
API Key

Get ward zone by city name

ParamInTypeReqDescription
citypathstringyesCity name (e.g. Chattogram)
GET/api/v1/ward-zones/:id
API Key

Get ward zone by ID

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/ward-zones/city/Dhaka" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": {
    "city": "Dhaka",
    "total_zones": 10,
    "total_wards": 129,
    "areas": [
      "Dhanmondi",
      "Gulshan",
      "Mirpur"
    ],
    "zones": [
      {
        "zone": 1,
        "centroid": {
          "lat": 23.81,
          "lon": 90.41
        },
        "wards": [
          1,
          2,
          3,
          4,
          5
        ],
        "ward_count": 5
      }
    ]
  }
}

Routing

5 endpoints
GET/api/v1/routing/route
API Key

Turn-by-turn directions between two coordinates. Returns distance, duration, and (optionally) per-step instructions plus a GeoJSON LineString geometry.

ParamInTypeReqDescription
fromquerystringyesOrigin "lat,lng"
toquerystringyesDestination "lat,lng"
viaquerystringnoOptional waypoints "lat,lng;lat,lng"
profilequerystringnodriving | walking | cycling (default: driving)
stepsquerybooleannoInclude per-step instructions
alternativesquerybooleannoSuggest alternative routes
overviewquerystringnosimplified | full | false
geometriesquerystringnogeojson | polyline | polyline6

Response: distance_m, duration_s, geometry, legs[], waypoints

POST/api/v1/routing/route
API Key

Same as GET /routing/route but accepts an array of coordinates in the body (more than two waypoints, or coordinates that would overflow a query string).

ParamInTypeReqDescription
coordinatesbodyarrayyesArray of {lat, lng} (min 2)
profilebodystringnodriving | walking | cycling
stepsbodybooleannoInclude per-step instructions
alternativesbodybooleannoSuggest alternative routes
GET/api/v1/routing/nearest
API Key

Snap a single point to the nearest road on the routing network.

ParamInTypeReqDescription
latquerynumberyesLatitude
lngquerynumberyesLongitude
profilequerystringnodriving | walking | cycling
POST/api/v1/routing/match
API Key

Snap a noisy GPS trace to the road network. Returns matched route segments.

ParamInTypeReqDescription
coordinatesbodyarrayyesArray of {lat, lng}
timestampsbodyarraynoPer-coordinate epoch seconds (improves quality)
profilebodystringnodriving | walking | cycling
POST/api/v1/routing/table
API Key

Distance / duration matrix between many coordinates (one-to-many or many-to-many).

ParamInTypeReqDescription
coordinatesbodyarrayyesArray of {lat, lng}
sourcesbodyarraynoIndices into coordinates to use as sources
destinationsbodyarraynoIndices into coordinates to use as destinations
annotationsbodystringnoduration | distance | duration,distance

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/routing/route" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    "..."
  ]
}

Roads

3 endpoints
GET/api/v1/roads/nearest
API Key

Find the road segment whose centerline is closest to a lat/lng.

ParamInTypeReqDescription
latquerynumberyesLatitude
lngquerynumberyesLongitude (lon also accepted)
maxMetersquerynumbernoSearch radius in meters (default 200)

Response: Road document with name, highway class, ref, length_m, GeoJSON LineString

GET/api/v1/roads/in-bbox
API Key

List road segments overlapping a bounding-box viewport. Useful for drawing a road overlay on a map.

ParamInTypeReqDescription
minLatquerynumberyesBounding box south latitude
minLngquerynumberyesBounding box west longitude
maxLatquerynumberyesBounding box north latitude
maxLngquerynumberyesBounding box east longitude
limitquerynumbernoCap results (default 500, max 2000)
classesquerystringnoComma-separated highway classes filter, e.g. "motorway,primary"
GET/api/v1/roads/search
API Key

Full-text search across road name + ref (e.g. "N1", "Mirpur Road").

ParamInTypeReqDescription
qquerystringyesSearch query
limitquerynumbernoCap results (default 20, max 100)

Code Example

curl -X GET "https://rasta-mapen-server.vercel.app/api/v1/roads/nearest" \
  -H "x-api-key: YOUR_API_KEY"

Sample Response

{
  "success": true,
  "data": [
    "..."
  ]
}

Rate Limiting

API requests are rate-limited based on your subscription plan. Exceeding your limit returns 429 Too Many Requests.

PlanDailyMonthly
Free50015,000
Starter5,000150,000
Growth25,000750,000
Enterprise100,0003,000,000

Limits reset at midnight UTC. Check X-RateLimit-Remaining header for real-time usage.

Rate Limit Headers

HTTP/1.1 200 OK
X-RateLimit-Limit: 500
X-RateLimit-Remaining: 423
X-RateLimit-Reset: 1712361600

---

HTTP/1.1 429 Too Many Requests
{
  "success": false,
  "message": "Daily limit exceeded",
  "retryAfter": "2024-04-06T00:00:00Z"
}

Error Codes

CodeMeaning
200Success
400Bad Request — invalid parameters
401Unauthorized — missing or invalid API key
403Forbidden — insufficient permissions
404Not Found — resource does not exist
429Rate Limited — daily or monthly limit exceeded
500Server Error — something went wrong

Error Response Format

{
  "success": false,
  "message": "Invalid API key",
  "errorMessages": [
    {
      "path": "x-api-key",
      "message": "API key is missing or invalid"
    }
  ]
}
{
  "success": false,
  "message": "Validation error",
  "errorMessages": [
    {
      "path": "lat",
      "message": "Latitude is required"
    },
    {
      "path": "lon",
      "message": "Longitude is required"
    }
  ]
}