Developed by: Engr. Md. Alamgir Kobir | Contact: bdgeo@makobir.com.bd
Last Updated:

Bangladesh Location API

This API provides location data for Divisions, Districts, Upazilas, Unions, and Villages in Bangladesh.

Authentication

All API requests must include the following headers:


X-API-KEY: YOUR_API_KEY
X-API-DOMAIN: YOUR_DOMAIN_NAME
Note: Ensure your domain is registered with the API provider and matches the domain used in X-API-DOMAIN.

API Endpoints

1. Get Divisions

GET /makobir.com.bd/bdgeo/get/divisions

2. Get Districts by Division

GET /makobir.com.bd/bdgeo/get/districts/{division_id}

3. Get Upazilas by District

GET /makobir.com.bd/bdgeo/get/upazilas/{district_id}

4. Get Unions by Upazila

GET /makobir.com.bd/bdgeo/get/unions/{upazila_id}

5. Get Villages by Union

GET /makobir.com.bd/bdgeo/get/villages/{union_id}

Response Format

[
  {
    "id": 1,
    "name_en": "Dhaka",
    "name_bn": "ঢাকা"
  },
  ...
]

Sample Usage

PHP (cURL)


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://makobir.com.bd/bdgeo/get/divisions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'X-API-KEY: YOUR_API_KEY',
  'X-API-DOMAIN: yourdomain.com'
]);
$response = curl_exec($ch);
curl_close($ch);

$data = json_decode($response, true);
print_r($data);

Python (requests)


import requests

headers = {
    'X-API-KEY': 'YOUR_API_KEY',
    'X-API-DOMAIN': 'makobir.com.bd'
}

response = requests.get('https://makobir.com.bd/bdgeo/get/divisions', headers=headers)
data = response.json()
print(data)

Node.js (fetch)


const fetch = require('node-fetch');

fetch('https://makobir.com.bd/bdgeo/get/divisions', {
  headers: {
    'X-API-KEY': 'YOUR_API_KEY',
    'X-API-DOMAIN': 'makobir.com.bd'
  }
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error('Error:', err));

Multilingual Support

Each response object contains:



BDGeo Locations Wordpress Plugin Documentation

A WordPress plugin for Bangladesh location selection with dependent dropdowns that works with popular form plugins.

Installation

  1. Upload the plugin ZIP file through WordPress admin (Plugins → Add New → Upload Plugin)
  2. Activate the plugin
  3. Configure your API key in BDGeo Locations → Settings

Basic Usage

Shortcode

The simplest way to use the plugin:

[bdgeo_location_selector]

This will show all available location fields (Division, District, Upazila, Union, Village).

Form Submission Data

When submitted, the form will include these fields for each level:

Field Name Description Example Value
division Selected division ID or name (based on format) 3 or ঢাকা
division_id Always contains the division ID 3
division_name Name in current language setting ঢাকা or Dhaka
division_name_bn Always contains Bangla name ঢাকা
division_name_en Always contains English name Dhaka

Advanced Usage

Customizing Fields

Specify which fields to display:

[bdgeo_location_selector fields="division,district,upazila"]

Available fields: division, district, upazila, union, village

Submitting Names Instead of IDs

To submit location names instead of IDs:

[bdgeo_location_selector name_format="name"]

Combining Options

[bdgeo_location_selector fields="division,district" name_format="name"]

Integration with Form Plugins

Contact Form 7

Simply add the shortcode to your form:

<div class="bdgeo-fields">
    [bdgeo_location_selector fields="division,district"]
</div>

Gravity Forms

Add an HTML field and insert the shortcode:

<div class="ginput_container">
    [bdgeo_location_selector fields="division,district,upazila"]
</div>

WPForms

Use the HTML field to add the shortcode:

<div class="wpforms-field">
    [bdgeo_location_selector]
</div>

Processing Form Submissions

Here's how to handle the submitted data in PHP:

// Get the submitted data
$division_id = sanitize_text_field($_POST['division_id']);
$division_name = sanitize_text_field($_POST['division_name']);
$division_name_bn = sanitize_text_field($_POST['division_name_bn']);
$division_name_en = sanitize_text_field($_POST['division_name_en']);

// Store in database
$location_data = [
    'division_id' => $division_id,
    'division_name' => $division_name,
    'division_name_bn' => $division_name_bn,
    'division_name_en' => $division_name_en,
    // Repeat for other levels
];

// Display based on current language
$current_lang = get_option('bdgeo_language', 'bn');
$display_name = ($current_lang === 'bn') ? $division_name_bn : $division_name_en;
echo "Selected Division: " . esc_html($display_name);

Frequently Asked Questions

How do I change the language?

Go to BDGeo Locations → Settings and select your preferred language (English or Bangla).

Why are my locations not loading?

Check that:

  1. Your API key is valid in the plugin settings
  2. The API server is accessible from your website
  3. You have a stable internet connection

Can I customize the appearance?

Yes! Add this CSS to your theme:

#bdgeo-location-wrapper select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    margin-right: 10px;
    margin-bottom: 10px;
    min-width: 200px;
}
Pro Tip: Use the name_format="name" parameter if you need to display the submitted values directly without database lookups.
Important: Always sanitize and validate the submitted data before storing in your database.

Support

If you need help or want to request access, please contact: hello@makobir.com.bd

Cell and WhatsApp
+880 1911143338 +880 1911143338