Quick access to the API: https://geocoder.ca/some_location?desired_output - Geocoding Examples | Autocomplete
XML/Json/CSV port API. You must sign up to use this port. (Cost: $1 for 200 lookups. Lookup credits, once purchased never expire. Every regular API lookup costs 1 credit regardless of the response) If you are a non-profit or want to view the free xml port head over here .
Geocoder.ca provides a simple XML interface to do real-time automated geocoding for your application.
JSON: If you wish to obtain JSON output, you must specify the (jsonp=1 and callback ) or json=1 as input parameters on top of the usual xml parameters.
(JSONP stands for JSON with padding , i.e. you put a string at the beginning and a pair of parenthesis around it. Here is a website explaining the difference .)
See the examples section for more information.
CSV: You may also obtain output in CSV format by replacing geoit=XML with geoit=CSV
Geocoding API : Reverse Geocoding API - Intersection Geocoding API - [User supplied coding and documentation material ]
Main Geocoding server: geocoder.ca
Specifications:
Input
The following parameters must be sent to https://geocoder.ca using either a GET or POST HTTP method. (Use https://geocoder.ca to send and receive data encrypted over SSL)
Parameter Name Description Permitted Values
auth
The authentication code for unthrottled service.
A string up to 30 bytes long. This code identifies you as a premium user and keeps track of the number of lookups you make.
locate
The location may be a street address, an intersection, a zip code, an ip address or any other combination of location entities. for example 330 metcalfe ottawa or metcalfe & wellington ottawa
This is a required parameter for forward geocoding. The other parameters (addresst, stno, city, etc) have been deprecated but will continue to be supported for backwards compatibility.
scantext
Free form text containing locations. for example This and That and the Other street in Porters Lake Nova Scotia
text containing one or more locations. The output will contain the locations found in the order of the confidence score.
bounds
The bounds parameter defines the latitude/longitude coordinates of the southwest and northeast corners of this bounding box using a pipe (|) character to separate the coordinates to bias the search results within that bounding box for geoparsing functions (scantext ) or single response geocoding (locate )
For example:
bounds=34.172684,-118.604794|34.236144,-118.500938
(you may also use prov={two letter state or province abbreviation} or city={city name} for city and state/province biasing)
country
The country parameter defines the
country
to bias the search results for geoparsing functions (scantext ) or single response geocoding (locate )
For example:
country=usa (bias to USA) or country=canada (bias to Canada)
region
The region parameter defines the
region
to limit the search results for geoparsing functions (scantext ) or single response geocoding (locate )
For example:
region can be a 2 letter state or province code. for eg, region=NY (bias geo parsing in the state of New York)
To limit responses to just Canada try region=canada , for the USA try region=usa
strict
Optional Parameter for enabling strict parsing of free form location input.
1.
standard
Return the properly formated "standartized" address in the response.
This is an optional parameter for address standardization. There is only one valid value: 1
decimal
An integer positive number.
This is an optional parameter to limit the number of decimal places in the response. (note that a small number will reduce accuracy)
geoit
The output type desired.
Only one of two allowed values: XML or CSV
json
Output in JSON format.
Optionally you may request data in JSON format. Accepted value: 1
jsonp
Output in JSONP format.
Optionally you may request data in JSONP format. Accepted value: 1
callback
Callback string if Output is in JSONP format.
Optionally you may request data in JSONP format. The callback can be any string value. Example 1 | Example 2
utm
Output latitude/longitude pair in The Universal Transverse Mercator (UTM) geographic coordinate system.
Optional. Accepted value: 1 Example
id
optionally you can include your own transaction id. this will be returned along with the response if provided.
a number or string no longer that 15 bytes.
strictmode
Optionally you can prevent geocoder from making guesses on your input - for example if you enter just a city name without the state or province, instead of geocoder determining the most likely city, it will let you chose from a list of suggestions.
Allowed values are Integer 0 or 1.
showcountry
Optionally - You may request that the country code is returned with the response. Only two possible values: US or CA.
Only one allowed value: 1
showpostal
Optionally - If you supply just a street address (or intersection), the showpostal parameter will instruct the algorithm to return the postal code of the location along with the latitude/longitude pair.
Only one allowed value: 1
showaddrs
Optionally - If you supply a postal or zip code with your query, the showaddrs option will attempt to return all addresses associated with that zip or postal code.
Only one allowed value: 1
Example
API access to the showaddrs function is available only to premium API subscribers, it costs 1 credit per data item. One data item in this case is equal to one address. Some postal codes are associated with a large number of addresses - so use with caution (unless you have an
Unlimited credit subscription ).
You may also use the limit parameter to prevent excessive credit use. For eg: &limit=100 will limit the response to the top 100 matches, hence only 100 credits will be spent.
To limit the responses to a certain street, use the street parameter.
For eg., https://geocoder.ca/?locate=83313&showaddrs=1&geoit=xml&street=riverside
autocomplete
Autocomplete Canadian Postal Addresses by setting the autocomplete parameter with the locate input string.
Only one allowed value: 1
XML Example / Json Example
API access to the autocomplete function is available only to premium API subscribers.
Example Request string:
https://geocoder.ca/?autocomplete=1&locate=1435%20prince&geoit=xml&auth=test
/
https://geocoder.ca/?autocomplete=1&locate=1435%20prince&geoit=xml&auth=test&json=1
postalinpolygon
Optionally - If you supply a polygon boundary described as latitude,longitude points divided by the pipe char "|", the postalinpolygon option will return all postal codes inside that polygon.
Only one allowed value: latitude,longitude,longitude|...
Example
API access to the postalinpolygon function is available only to premium API subscribers, it costs 1 credit per data item. One data item in this case is equal to one postal code. Large polygons contain a large number of postal codes - so use with caution.
batchpostal
You may supply more than one postal codes in your query, separated by a pipe ( | ), in the batchpostal parameter.
Pipe separated postal codes: K2C1N5 | E4L1B3 | M2N1N5 ...
Example: ?batchpostal=k2c1n5| m2n1n4| K1T0G5&geoit=xml&auth={your auth code}
API access to the batchpostal function is available only to premium API subscribers, it costs 1 credit per data item. One data item in this case is equal to one postal code.
censusdatafromdauid
You may obtain additional census data from the dauid parameter that is returned with a postal code or location lookup in Canada.
Example: ?censusdatafromdauid=59350105&geoit=xml&auth={your auth code}
API access to the censusdatafromdauid function is available only to premium API subscribers, it costs 1 credit per data item.
topmatches
Optionally - If you supply a partial street address and wish to obtain a fixed number of the most likely suggestions, send a
value through this parameter.
This must be the maximum number of suggestions desired in the response. The topmatches parameter value must be a positive integer.
postal
(Deprecated) A six letter canadian postal code or a US Zip5 or Zip+4 Code
The postal code format should follow the following format ANANAN where N represents a number and A a letter.
getpolygon
Optional parameter to return the postal code polygon boundary
Only one allowed value: 1 Example
boundary
Lookup a neighborhood's boundary.
Only one allowed value: Neighborhood name. Only available in CSV output format. . For example:
https://geocoder.ca/?boundary=Financial%20District,Toronto,43.647151,-79.379769&geoit=csv&auth=your-auth-code
addresst
(Deprecated) The name of the street address.
(Deprecated) A string no longer that 220 bytes.
stno
(Deprecated) Street Number
(Deprecated) A number.
city
(Deprecated) The City Name
(Deprecated) A string no longer that 220 bytes.
prov
(Deprecated) The Two letter Canadian province code or US state abbreviation.
(AB,BC,MB,NB,NL,NS,NT,NU,ON,PE,QC,SK,YT)
Input Requirements:
You must provide your authentication code (auth ) and some location entity (try placing as much location information as possible in the 'locate' parameter).
The parameter geoit =XML is also required for the XML port.
Output
The output may contain the following XML or JSON formated parameters.
Parameter Name Description Expected Output Values
latt
The latitude.
A decimal number.
longt
The longitude.
A decimal number.
remaining_credits
The remaining lookup credits in your account.
An integer number. The minimum value is -100. This is to give you some "buffer" zone and ample notice to replenish your lookup credits in case your balance runs low. If the remaining credits drops below -100 you will not be able to make any more lookups. If that happens you may login to your account to obtain more credits.
id
Transaction id.
If supplied in the input the transaction id will be returned along with the output.
stnumber
In case you requested a properly formated address to be returned.
The street number (integer value).
staddress
In case you requested a properly formated address to be returned.
The formated street address.
city
In case you requested a properly formated address to be returned.
The city name.
prov
In case you requested a properly formated address to be returned.
The province code.
postal
The postal or zip code.
LSD
Alberta Township System (ATS) variant of the Dominion Land Survey (DLS) system as implemented in Canada.
It consists of legal subdivisions (LSD) except place the tick at the one-quarter way points. LSDs are numbered sinusoidally starting at the southeast corner of the section.
TimeZone
The Time Zone Code.
AreaCode
The telephone area code.
confidence
The Geocoding Confidence Score is a number representing our accuracy estimate on a geocoding request. This number ranges from 1 to 0. A higher score indicates a closer match (A score of 1 meaning best match accuracy.) A result with confidence score less than 0.5 is never returned to the user (it will most likely result in a suggestion being returned), except for ip address geocoding where rough approximations are allowed as in most cases we are looking at city level accuracy.
a number [0..1] 1=best match, 0=no response.
more
The part of the input which was not used to compute the location. This may be useful if you wish to extract non-geographical information from an address string, such as P.O. Boxes
, Apartment/Unit numbers, etc.
For example: 1 valhalla inn road apt 1009 etobicoke
Output:
{ "standard" : { "staddress" : "Valhalla Inn RD", "stnumber" : "1", "prov" : "ON", "city" : "Etobicoke", "confidence" : "0.9" }, "TimeZone" : "America/Toronto", "postal" : "M9B1S9", "AreaCode" : "289", "latt" : "43.641478", "longt" : "-79.557689", "Dissemination_Area" : { "adauid" : "35200316", "dauid" : "35204249" }, "more" : "apt 1009" }
Error Codes:
The output could contain an error code. If your query does not produce coordinates the latt and longt containers will be empty.
These are the error codes that could be returned upon an unsuccessful lookup:
001
ip_address is not allowed to use authentication token: auth
(in case you decide to restrict the use of your token to a specific ip address, and the incoming ip does not match)
002
auth has ran out of credits.
(in case you have used over 100 credits over your total balance)
003
Authentication token: auth not found.
005
Postal Code is not in the proper Format.
004
Specify either a Canadian province two letter code or a US two letter state abbreviation.
007
Supply a valid query.
008
Your request did not produce any results. Check your spelling and try again.
Sometimes when a location is not found a suggestion (or more) will be contained within <suggestion> xml tags. for example:
or
https://geocoder.ca/?locate=Thornton&geoit=xml&standard=1&topmatches=1&strictmode=1
in case the topmatches parameter is supplied, the most likely matches will be returned up to the number requested.
for example, this request will return the top 5 suggestions for the following improperly formed address:
https://geocoder.ca/?locate=200+mutcalf%2C+ottawa+on&geoit=xml&&topmatches=5
Note: 1 successful lookup costs 1 credit. You can buy 2 credits for 1c.
Cross Street geocoding involves finding the coordinates of the point where two given streets intersect.
Cross Street Intersection Geocoding Specifications:
Input
The following parameters must be sent to https://geocoder.ca using either a GET or POST HTTP method.
Parameter Name Description Permitted Values
street1
The name of the first street
A string no longer that 220 bytes.
street2
The name of the second street
A string no longer that 220 bytes.
city
The City Name
A string no longer that 220 bytes.
prov
The Two letter Canadian province code or two letter US state abbreviation.
(AB,BC,MB,NB,NL,NS,NT,NU,ON,PE,QC,SK,YT)
locate
Optionally you can specify a location. for example 330 metcalfe ottawa or metcalfe & wellington ottawa
This is an optional parameter for your convenience. We will parse out an address or intersection from it.
decimal
An integer positive number.
This is an optional parameter to limit the number of decimal places in the response. (note that a small number will reduce accuracy)
cross
A boolean value indicating the type of geocoding desired.
an integer of value 1
geoit
The output type desired.
Only one allowed value: XML
id
optionally you can include your own transaction id. this will be returned along with the response if provided.
a number or string no longer that 15 bytes.
showpostal
Optionally - If you supply just a street address (or intersection), the showpostal parameter will instruct the algorithm to return the postal code of the location along with the latitude/longitude pair.
Only one allowed value: 1
Output
Similarly to forward geocoding Upon a successful request you will see an xml response such as this one:
xx.yyyyyyyyy
-xx.yyyyyyyyy
City Name
Two letter province code
Street1
Street2
number of remaining credits : integer value
Possible extra Error Codes related to intersection geocoding.
010
Two streets, the province and the city name are required.
Suggestion System:
Sometimes a suggestion will be provided upon an unsucessful request.
for example:
<suggestion>
<suggstreet1>MEADOWLANDS DR E</suggstreet1>
<suggstreet2>PRINCE OF WALES DR </suggstreet2>
<city>nepean</city>
<prov>ON</prov>
</suggestion>
Reverse geocoding is the process whereupon you supply a point expressed as a latitude-longitude pair and get the closest civic street address to this pair, and also the postal/zip code, the nearest intersection, the nearest major intersection, and the road having the smallest vertical distance to this point, and (optionally) the nearest points of interest (See Places Search API ).
Reverse Geocoding Specifications:
Input
For performing reverse geocoding The following parameters must be sent to https://geocoder.ca using either a GET or POST HTTP method.
Parameter Name Description Permitted Values
latt
The Latitude.
A decimal number.
longt
The Longitude.
A decimal number.
range
The optional range to limit the reverse geocoding.
A number.
exact
Optional. If specified geocoder will attempt to find an exact match (meaning the reverse of a rooftop geocoding request).
1.
moreinfo
The optional moreinfo parameter will cause the xml port to return the county and metro area information.
1.
allna
The optional allna parameter indicates that you wish to perform the reverse geocoding in both the USA and Canada, in some cases (for areas close to the border) obtaining two results instead of one. This parameter is also required for reverse geocoding in the US.
1.
decimal
An integer positive number.
This is an optional parameter to limit the number of decimal places in the response. (note that a small number will reduce accuracy)
reverse
An integer indicating your interface preference.
valid values is integer 1.
geoit
The output type desired.
Only one allowed value: XML
id
optionally you can include your own transaction id. this will be returned along with the response if provided.
a number or string no longer that 15 bytes.
corner
Optionally you can obtain the nearest street intersection to a latitude/longitude pair.
Only one allowed value: 1
Input Requirements:
You must provide a latitude-longitude pair and the reverse and geoit parameters.
Output
The output will contain these parameters in XML or JSON format.
Parameter Name Description Expected Output Values
latt
The latitude of the result.
A decimal number.
longt
The longitude of the result.
A decimal number.
city
The city of the result set
prov
The province
postal
The postal code.
stnumber
The street number.
staddress
The street address.
postal
The postal or zip code.
LSD
Alberta Township System (ATS) variant of the Dominion Land Survey (DLS) system as implemented in Canada.
It consists of legal subdivisions (LSD) except place the tick at the one-quarter way points. LSDs are numbered sinusoidally starting at the southeast corner of the section.
TimeZone
The Time Zone Code.
AreaCode
The telephone area code.
inlatt
The input latitude.
inlongt
The input longitude.
distance
The distance of the result location from the input location.
NearRoad
The nearest Road to the input point.
NearRoadDistance
The distance of the nearest Road to the input point.
neighborhood
The city neighborhood that the input point falls in.
If a us location is returned by the reverse geocoding engine the response will be contained within <usa> tags. For example:
Optionally the output may contain additional information the closest street corner as well as the closest major intersection - These responses will be held inside respectively <intersection> and <major_intersection> xml tags:
street1
The first street of the intersection.
A string
street2
The second street of the intersection.
A string
lattx
The latitude of the intersection.
A decimal number
longtx
The longitude of the intersection.
A decimal number
city
The city of the intersection.
A string
prov
The province of the intersection.
The two letter Canadian province code or US two letter state abbreviation.
distance
The distance of the intersection from the input location.
A decimal number expressed in kilometres
Possible extra error codes related to reverse geocoding:
009
The latitude and longitude you provided are not in the valid range.
yy.yyy
-xx.xxx
Extra parameters :
strict - Value: 1 - Perform a strict match
nopostal - Value: 1 - Ignore the postal code (i.e. return a street level match only)
More Reverse Geocoding:
You may also make reverse geocoding lookups using a canadian postal code or a US zip code as input. The output may be provided in XML or Jsonp.
For Example: XML | Jsonp
In the postal input parameter you can provide a 5 digit zip code (eg. 75704), or a zip+4 (eg. 75704-2933) code or a Canadian Postal code (eg. K2C1N5).
Similarly you may use a locate input parameter with a regular street address as its value. Example .
Reverse Place Search API:
Optionally you may request the nearest points of interest to be returned with your reverse geocoding search.
Reverse Geocoding with Place Search Specifications:
Input
Following are the parameter names you may use if you also require places data.
Parameter Name Description Permitted Values
pois
Flag indicating place search.
Only one permitted value: 1 .
type (optional)
The Place type, for eg. restaurant . Follow these links for the full list of place type strings for Canada and The USA
A String matching a valid category type for either Canada or The USA .
radius (optional)
The radius of place search in meters. If omited, the system will automatically compute a radius based on the area; dense areas will have a small radius, while sparse areas a bigger value of the radius up to 1.5 kilometres.
An Integer Number. (for eg: radius=100 narrow search withing 100 metres of the input point.
keyword (optional)
A Search keyword.
A string. For example, keyword=Subway narrow matches to the Subway brand of restaurants. If the keyword parameter is sent, the type parameter is ignored.
Output
The output will contain these parameters in XML or JSON format under the pois ->poi tags.
Parameter Name Description Expected Output Values
name
The name of the place.
A String.
distance_km
The distance from the input point in kilometres.
A decimal number.
main_category
The main category type of the place
A string.
second_category
The second category type of the place (if applicable)
A string.
adr
The street address of the place
A string
city
The city name
A string
neighborhood
The neighborhood
A string
poi_tel
The telephone number
A string
location_id
location_id is the geocode number. Every 10m by 10m square of the earth is converted to a unique integer, also known as the geo number.
Nearby locations have location ids with small difference.
An integer number
area_id
The area_id roughly corresponds to the area of a city and is derived from the location_id
An integer number
small_area_id
The small_area_id roughly corresponds to seveal city blocks and is derived from the location_id
An integer number
latitude
The latitude of the place
A decimal number
longitude
The longitude of the place
A decimal number
prov
The Province or State Abbreviation
2 digit Character code
postal
The postal or zip code
A 6 digit string or a 5 digit zip code.
formatted_address
The full address of the place
A string
source_url
The web url of the point of interest
A string
crawl_time
The time the place information was updated
A datetime string
opening_hours
The hours of operation
A formated string containing the opening hours for the 7 days of the week
Example 1: https://geocoder.ca/45.415263,-75.688055?pois=1&type=restaurant&radius=200&geoit=xml - Reverse geocode 45.415263,-75.688055 and get all Points of Interest matching the category restaurant within a radius of 200 meters in XML Format.
Example 2: https://geocoder.ca/45.415263,-75.688055?pois=1&keyword=elgin&radius=200&geoit=xml - Reverse geocode 45.415263,-75.688055 and get all Points of Interest matching the keyword elgin within a radius of 200 meters in XML Format.
Example 3: https://geocoder.ca/45.415263,-75.688055?pois=1&geoit=xml&json=1 - Reverse geocode 45.415263,-75.688055 and get all nearby Points of Interest in JSON Format.
Example Response:
Elgin Street Diner
0.028
Restaurant
Delivery Restaurant
374 Elgin St
Ottawa
Golden Triangle
16132379700
2451476848974
206329
245147684
45.414904
-75.688066
ON
K2P1N1
374 Elgin St Ottawa ON K2P1N1 Canada
www.elginstreetdiner.com/
2021-04-28 16:58:04
...
Matching Functions:
You can match partial street names.
For example:
https://geocoder.ca/?cityname=Ottawa&provname=on&streetname=metcalfe&matchonly=1&geoit=xml
222
Matched results.
K1S3P3
508
METCALFE ST
Ottawa
ON
45.4086980000
75.6853960000
METCALFE
ST
K1S3P3
506
METCALFE ST
Ottawa
ON
45.4087500000
75.6854390000
METCALFE
ST
K2P1P9
....
It works both for USA and Canada. The parameters cityname , provname , streetname , matchonly , geoit=xml are required.
Alternatively you may use the bounds parameter to limit your matches within a bounding box:
https://geocoder.ca/?streetname=Brookside&geoit=xml&matchonly=1&bounds=43.377996,-79.604857|43.677996,-79.304857
222
Matched results.
4
112
Brookside AVE
YORK
ON
110
Brookside DR
Toronto
ON
31
Brookside DR
Oakville
ON
29
Brookside AVE
Toronto
ON
A Simple Example:
This is a simple interface to the geocoder.ca API written in perl.
There are other interfaces to geocoder.ca freely downloadable on the web that use php, python, C, C++, etc..
New ones pop up all the time. A simple web search will probably reveal more.
#!/usr/bin/perl -w
#------------------------------------------------------------------#
#simple perl implementation api to the geocoder.ca xml server. #
#written by ervin ruci. #
#Requirements: #
# Perl Module : LWP. (from www.cpan.org) #
#also perl version 5.6.1 or greater is recomended but not required.#
#------------------------------------------------------------------#
use strict;
#these are the data that will be passed in as input
my $street_number = '101';
my $street_name = 'Wellington';
my $city = 'Ottawa';
my $province = 'ON';
my $postal = '';
my $id = 'req10001';
my $auth = '112078514150417x1'; #your authentication code for unthrottled access to the API
my %data; #this hash will hold the parsed output
my $url = "https://geocoder.ca" . "/?" . "stno=" . $street_number . "&addresst=" . $street_name . "&city="
. $city . "&prov=" . $province . "&postal=" . $postal . "&id=" . $id . "&geoit=XML" . "&auth=" . $auth;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
$ua->agent("ruci/0.1 " . $ua->agent);
my $req = new HTTP::Request('GET', $url);
$req->header(Subject => 'XML Get',
From => '[email protected] ',
timeout => '3*10');
my $res = $ua->request($req);
if ($res->is_success) {
my $result = $res->content;
if ($result =~ /<latt>(.*)<\/latt>/) {
$data{latt} = $1;
}
if ($result =~ /<longt>(.*)<\/longt>/) {
$data{longt} = $1;
}
if ($result =~ /<id>(.*)<\/id>/) {
$data{id} = $1;
}
} else {
print "Error... The server said: " . $res->code . $res->message . "\n\n";
}
print "Got Latitude " . $data{latt} . "\n";
print "Got Longitude " . $data{longt} . "\n";
print "Additional Information " . $data{id} . "\n";
###################################################
######### That's It! ##############################
###################################################
Here is the output from this code:
Got Latitude 45.423361
Got Longitude -75.698537
Additional Information req10001
......................................
Here is another example illustrating a reverse geocoding client that uses the POST HTTP method
sub geocodercareverse {
my ($latt,$longt) = @_;
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = new LWP::UserAgent;
$ua->agent("ruci/0.1 " . $ua->agent);
my $res = $ua->request(POST 'https://geocoder.ca',
[
'latt' => $latt,
'longt' => $longt,
'geoit' => 'XML',
'auth' => '29876124912837723192x1',
'allna' => '1',
'reverse' => '1'
]
);
my ($ststn,$stadr,$stcity,$stprov,$szip);
if ($res->is_success) {
my $result = $res->content;
if ($result =~ /(.*)<\/uscity>/) {
$stcity = $1;
}
if ($result =~ /(.*)<\/state>/) {
$stprov = $1;
}
if ($result =~ /(.*)<\/usstnumber>/) {
$ststn = $1;
}
if ($result =~ /(.*)<\/usstaddress>/) {
$stadr = $1;
}
if ($result =~ /(.*)<\/zip>/) {
$szip = $1;
}
} else {
print STDERR "Error... The server said: " . $res->code . $res->message . "\n\n";
}
return ($ststn,$stadr,$stcity,$stprov,$szip);
}