Canadian Postal Code (FSA & LDU) Geocoding Guide
Resolve Canadian postal codes and Forward Sortation Areas to exact coordinates, bounding boxes, and municipal boundaries with sub-second latency and zero request logging.
Understanding Canadian Postal Code Architecture
Canadian postal codes follow the alphanumeric format A1A 1A1 (alternating letters and digits). They are divided into two distinct hierarchical units:
Identifies a major geographic region, province district, or large city sector (e.g., M5V in Downtown Toronto or H2X in Downtown Montréal).
Pinpoints a specific urban street block, high-density residential apartment building, or commercial office tower (e.g., 2T6).
Querying the Postal Code Geocoding API
Mapacan provides two ways to look up Canadian postal codes: structured parameters (recommended for clean programmatic workflows) and freeform search.
Method 1: Structured Search (Fastest & Most Accurate)
GET /search
Pass the postal code in the postalcode parameter and restrict matching strictly to Canada with countrycodes=ca.
GET https://mapacan.ca/search?postalcode=M5V+2T6&countrycodes=ca&format=jsonv2
Method 2: FSA-Level Regional Lookup
Regional CentroidTo find the centroid and geographic boundary of an entire Forward Sortation Area (for territory planning or delivery zones), provide only the 3-character FSA:
GET https://mapacan.ca/search?postalcode=M5V&countrycodes=ca&format=jsonv2
API Response Structure
The service returns standard Nominatim JSONv2 output, including exact latitude/longitude coordinates and the bounding box extent:
[
{
"place_id": 367185658,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0",
"osm_type": "postcode",
"lat": "43.6425662",
"lon": "-79.3957241",
"category": "place",
"type": "postcode",
"place_rank": 30,
"importance": 0.35,
"addresstype": "postcode",
"name": "M5V 2T6",
"display_name": "M5V 2T6, Old Toronto, Toronto, Ontario, Canada",
"boundingbox": [
"43.6265662",
"43.6585662",
"-79.4117241",
"-79.3797241"
]
}
]
Code Examples
import requests
API_KEY = "your_server_key_here"
BASE_URL = "https://mapacan.ca/search"
def geocode_canadian_postal(postal_code: str):
clean_code = postal_code.strip().upper()
response = requests.get(
BASE_URL,
headers={"Authorization": f"Bearer {API_KEY}"},
params={
"postalcode": clean_code,
"countrycodes": "ca",
"format": "jsonv2"
},
timeout=5
)
response.raise_for_status()
results = response.json()
if not results:
return None
return {
"postal_code": clean_code,
"lat": float(results[0]["lat"]),
"lon": float(results[0]["lon"]),
"display_name": results[0]["display_name"]
}
print(geocode_canadian_postal("M5V 2T6"))
<?php
function lookupPostalCode(string $postalCode, string $apiKey): ?array
{
$url = 'https://mapacan.ca/search?' . http_build_query([
'postalcode' => strtoupper(trim($postalCode)),
'countrycodes' => 'ca',
'format' => 'jsonv2',
]);
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer {$apiKey}"],
CURLOPT_TIMEOUT => 5,
]);
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status !== 200 || ! $raw) {
return null;
}
$data = json_decode($raw, true);
if (empty($data)) {
return null;
}
return [
'lat' => (float) $data[0]['lat'],
'lon' => (float) $data[0]['lon'],
'name' => $data[0]['display_name'],
];
}
Zero Request Logging for Customer Postal Codes
Under Canadian privacy regulations (PIPEDA and Quebec's Law 25), individual postal codes linked to client transactions are considered personal information. Unlike US cloud APIs that retain address telemetry and query history for model training and profiling, Mapacan routes all queries in-memory with zero disk logging on bare metal in Beauharnois, Quebec.