Get API Key

Welcome to the API key generation guide. This section will walk you through the process of generating an API key for our service. Please follow the instructions carefully to ensure a smooth experience.

How to Generate Your API Key:

After successfully registering, follow these steps to generate your API key:

  1. Sign up at OpenAPI Box by completing the registration process.
  2. Once registered, log in and go to the API Services section of your dashboard.
  3. Search for Post Code API in the available services.
  4. Select the API that corresponds to your service.
  5. Look for the Generate API Key option and click it.
  6. A confirmation modal will appear. Confirm your action to proceed.
  7. Once confirmed, you will see the API key generated for your account.
  8. Click the Show API Key button to reveal your API key.
  9. Click the Copy button next to the key to copy it to your clipboard.

Post Code API

Get accurate and up-to-date postal code information for locations worldwide. This API is perfect for validating addresses, creating location-based features, or improving form submissions.

Endpoints

POST /GET https://openapibox.com/api/postcodeapi/YOUR-API-KEY/getInfo

Parameters
Field Name Description Required Example Values
country_code The country's ISO Code to filter data No (Optional) BD
postal_code The postal code to filter data No (Optional) 1000
place_name The place name to filter data No (Optional) Dhaka
admin_name1 The first-level administrative division to filter data No (Optional) Dhaka Division
accuracy The accuracy of the location data No (Optional) 0.95
latitude The latitude coordinate to filter data No (Optional) 25.2669
longitude The longitude coordinate to filter data No (Optional) 55.2934
limit The limit of records to return No (Optional) 100
Demo Code Examples
                                 
https://openapibox.com/api/postcodeapi/YOUR-API-KEY/getInfo?country_code=BD&postal_code=1000&place_name=Dhaka&admin_name1=Dhaka+Division&accuracy=0.95&latitude=25.2669&longitude=55.2934&limit=100

                                 
<?php

$endpoint = 'https://openapibox.com/api/postcodeapi/YOUR-API-KEY/getInfo';

// Optional parameters (you can modify these as needed)
$params = [
    'country_code' => 'BD', // Optional: Country code (e.g., 'BD' for Bangladesh)
    'postal_code' => '1000', // Optional: Postal code (e.g., '1000' for Dhaka)
    'place_name' => 'Dhaka', // Optional: Place name (e.g., 'Dhaka')
    'admin_name1' => 'Dhaka Division', // Optional: Admin name (e.g., 'Dhaka Division')
    'accuracy' => 0.95, // Optional: Accuracy (e.g., '0.95')
    'latitude' => 25.2669, // Optional: Latitude (e.g., '25.2669')
    'longitude' => 55.2934, // Optional: Longitude (e.g., '55.2934')
    'limit' => 100 // Optional: Limit of records to return (default 100)
];

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => $endpoint,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => http_build_query($params), // Send the parameters as a POST request
]);

$response = curl_exec($curl);

if ($response === false) {
    echo 'cURL error: ' . curl_error($curl);
} else {
    echo htmlentities($response);  // Display the response from the API
}

curl_close($curl);
?>

<?php


use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

// Create a new Guzzle client
$client = new Client();

// Replace 'YOUR-API-KEY' with your actual API Key and define the API endpoint
$endpoint = 'https://openapibox.com/api/postcodeapi/YOUR-API-KEY/getInfo';

// Set the optional parameters
$params = [
    'country_code' => 'BD', // Optional: Country code (e.g., 'BD' for Bangladesh)
    'postal_code' => '1000', // Optional: Postal code (e.g., '1000' for Dhaka)
    'place_name' => 'Dhaka', // Optional: Place name (e.g., 'Dhaka')
    'admin_name1' => 'Dhaka Division', // Optional: Admin name (e.g., 'Dhaka Division')
    'accuracy' => 0.95, // Optional: Accuracy (e.g., '0.95')
    'latitude' => 25.2669, // Optional: Latitude (e.g., '25.2669')
    'longitude' => 55.2934, // Optional: Longitude (e.g., '55.2934')
    'limit' => 100 // Optional: Limit of records to return (default 100)
];

// Make the POST request using Guzzle
try {
    $response = $client->post($endpoint, [
        'form_params' => $params // Send parameters as form data
    ]);

    // Display the response body safely
    echo htmlentities($response->getBody());
} catch (RequestException $e) {
    // Handle Guzzle-specific errors
    echo 'Guzzle error: ' . $e->getMessage();
}

?>

// Define the API endpoint and parameters
const endpoint = 'https://openapibox.com/api/postcodeapi/YOUR-API-KEY/getInfo';

// Optional parameters
const params = {
    country_code: 'BD', // Optional: Country code (e.g., 'BD' for Bangladesh)
    postal_code: '1000', // Optional: Postal code (e.g., '1000' for Dhaka)
    place_name: 'Dhaka', // Optional: Place name (e.g., 'Dhaka')
    admin_name1: 'Dhaka Division', // Optional: Admin name (e.g., 'Dhaka Division')
    accuracy: 0.95, // Optional: Accuracy (e.g., '0.95')
    latitude: 25.2669, // Optional: Latitude (e.g., '25.2669')
    longitude: 55.2934, // Optional: Longitude (e.g., '55.2934')
    limit: 100 // Optional: Limit of records to return (default 100)
};

// Create a POST request to the API
async function fetchApiData() {
    try {
        const response = await fetch(endpoint, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
            },
            body: new URLSearchParams(params).toString(), // Send parameters as form data
        });

        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }

        const data = await response.text(); // Parse the response as text
        console.log(data); // Log the response (or display it as needed)
    } catch (error) {
        console.error('Fetch error:', error);
    }
}

// Call the function to fetch API data
fetchApiData();


import requests

# Define the API endpoint and parameters
endpoint = 'https://openapibox.com/api/postcodeapi/YOUR-API-KEY/getInfo'

# Optional parameters
params = {
    'country_code': 'BD',  # Optional: Country code (e.g., 'BD' for Bangladesh)
    'postal_code': '1000',  # Optional: Postal code (e.g., '1000' for Dhaka)
    'place_name': 'Dhaka',  # Optional: Place name (e.g., 'Dhaka')
    'admin_name1': 'Dhaka Division',  # Optional: Admin name (e.g., 'Dhaka Division')
    'accuracy': 0.95,  # Optional: Accuracy (e.g., '0.95')
    'latitude': 25.2669,  # Optional: Latitude (e.g., '25.2669')
    'longitude': 55.2934,  # Optional: Longitude (e.g., '55.2934')
    'limit': 100  # Optional: Limit of records to return (default 100)
}

try:
    # Make a POST request
    response = requests.post(endpoint, data=params)
    
    # Check if the request was successful
    if response.status_code == 200:
        print(response.text)  # Print the response from the API
    else:
        print(f"HTTP error: {response.status_code}")
except requests.RequestException as e:
    print(f"Request error: {e}")


package main

import (
	"bytes"
	"fmt"
	"net/http"
	"net/url"
)

func main() {
	// Define the API endpoint
	endpoint := "https://openapibox.com/api/postcodeapi/YOUR-API-KEY/getInfo"

	// Define the parameters
	params := url.Values{}
	params.Add("country_code", "BD")       // Optional: Country code (e.g., 'BD' for Bangladesh)
	params.Add("postal_code", "1000")     // Optional: Postal code (e.g., '1000' for Dhaka)
	params.Add("place_name", "Dhaka")     // Optional: Place name (e.g., 'Dhaka')
	params.Add("admin_name1", "Dhaka Division") // Optional: Admin name (e.g., 'Dhaka Division')
	params.Add("accuracy", "0.95")        // Optional: Accuracy (e.g., '0.95')
	params.Add("latitude", "25.2669")     // Optional: Latitude (e.g., '25.2669')
	params.Add("longitude", "55.2934")    // Optional: Longitude (e.g., '55.2934')
	params.Add("limit", "100")            // Optional: Limit of records to return (default 100)

	// Create a new POST request
	req, err := http.NewRequest("POST", endpoint, bytes.NewBufferString(params.Encode()))
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}

	// Set headers
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

	// Send the request using the http.Client
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error making request:", err)
		return
	}
	defer resp.Body.Close()

	// Read and display the response
	buf := new(bytes.Buffer)
	buf.ReadFrom(resp.Body)
	fmt.Println(buf.String())
}



Example Responses


[
  {
    "id": 1394148,
    "country_code": "BD",
    "postal_code": "1000",
    "place_name": "Dhaka GPO",
    "admin_name1": "Dhaka Division",
    "admin_code1": "81",
    "admin_name2": "Dhaka",
    "admin_code2": "3026",
    "admin_name3": "Palton",
    "admin_code3": null,
    "latitude": 23.729,
    "longitude": 90.4112,
    "accuracy": null,
    "coordinates": {
      "lon": 90.4112,
      "lat": 23.729
    },
    "created_at": "2024-12-30 17:37:15",
    "updated_at": "2024-12-30 17:37:15"
  }
]



{
  "code": 1002,
  "message": "Invalid API Key"
}

Response Details

Field Name Values
Country Code BD
Postal Code 1000
Place Name Dhaka GPO
Admin Name 1 Dhaka Division
Admin Code 1 81
Admin Name 2 Dhaka
Admin Code 2 3026
Admin Name 3 Palton
Admin Code 3 None
Latitude 23.729
Longitude 90.4112
Accuracy None
Coordinates Latitude: 23.729
Longitude: 90.4112