Documentation menu
Docs / Cookbook / Resolve the zoning district at a street address

Resolve the zoning district at a street address

Geocode an address, then look up the zoning district at that exact coordinate.

1. Geocode the address to get lat/lng:

curl --request GET \
  --url 'https://api.builddata.ca/geocode?address=100 Queen St W, Toronto' \
  --header 'X-API-Key: YOUR_API_KEY'
import requests

url = "https://api.builddata.ca/geocode?address=100 Queen St W, Toronto"
headers = {"X-API-Key": "YOUR_API_KEY"}
resp = requests.get(url, headers=headers)
print(resp.json())
const res = await fetch("https://api.builddata.ca/geocode?address=100 Queen St W, Toronto", {
  headers: {
    "X-API-Key": "YOUR_API_KEY",
  },
});
const data = await res.json();
console.log(data);
<?php
$ch = curl_init("https://api.builddata.ca/geocode?address=100 Queen St W, Toronto");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "X-API-Key: YOUR_API_KEY",
]);
echo curl_exec($ch);
require "net/http"
require "uri"

uri = URI("https://api.builddata.ca/geocode?address=100 Queen St W, Toronto")
req = Net::HTTP::Get.new(uri)
req["X-API-Key"] = "YOUR_API_KEY"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
puts res.body
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.builddata.ca/geocode?address=100 Queen St W, Toronto", nil)
    req.Header.Add("X-API-Key", "YOUR_API_KEY")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.*;

HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.builddata.ca/geocode?address=100 Queen St W, Toronto"))
    .header("X-API-Key", "YOUR_API_KEY")
    .build();
HttpResponse<String> res = HttpClient.newHttpClient()
    .send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());

2. Pass the returned lat/lng to /zone:

curl --request GET \
  --url 'https://api.builddata.ca/zone?lat=43.6534&lng=-79.3841' \
  --header 'X-API-Key: YOUR_API_KEY'
import requests

url = "https://api.builddata.ca/zone?lat=43.6534&lng=-79.3841"
headers = {"X-API-Key": "YOUR_API_KEY"}
resp = requests.get(url, headers=headers)
print(resp.json())
const res = await fetch("https://api.builddata.ca/zone?lat=43.6534&lng=-79.3841", {
  headers: {
    "X-API-Key": "YOUR_API_KEY",
  },
});
const data = await res.json();
console.log(data);
<?php
$ch = curl_init("https://api.builddata.ca/zone?lat=43.6534&lng=-79.3841");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "X-API-Key: YOUR_API_KEY",
]);
echo curl_exec($ch);
require "net/http"
require "uri"

uri = URI("https://api.builddata.ca/zone?lat=43.6534&lng=-79.3841")
req = Net::HTTP::Get.new(uri)
req["X-API-Key"] = "YOUR_API_KEY"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |h| h.request(req) }
puts res.body
package main

import (
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.builddata.ca/zone?lat=43.6534&lng=-79.3841", nil)
    req.Header.Add("X-API-Key", "YOUR_API_KEY")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
import java.net.URI;
import java.net.http.*;

HttpRequest req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.builddata.ca/zone?lat=43.6534&lng=-79.3841"))
    .header("X-API-Key", "YOUR_API_KEY")
    .build();
HttpResponse<String> res = HttpClient.newHttpClient()
    .send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());

The /zone response returns the zoning district and description at that point. /zone resolves a polygon, so it answers for the coordinate exactly. The search endpoints treat lat/lng as the centre of an area and default to a 1 km radius; for one address rather than its neighbourhood, use the recipe below.

Ready to build?Create a free key and start calling BuildData in minutes. No card required.
Get your API key →