Posted on February 7, 2024

Enhance your search with the new proximity-based Autocomplete API

We are excited to announce a significant enhancement to the Township Canada API: the addition of the proximity-based suggestion capability in our Autocomplete API. This new feature is set to improve how you search for legal land descriptions, offering results tailored to a specific geographic area.

Proximity parameter: bringing precision to your searches

The newly introduced 'proximity' parameter allows you to bias search results towards a specific location. This means that when you search for a legal land description, the Autocomplete API will prioritize results closest to the coordinates you provide, enhancing the relevance and efficiency of your searches.

How to leverage the new parameter

Incorporating this new feature is straightforward. Here’s an example using cURL to demonstrate how you can use the proximity parameter:

curl -X GET 'https://developer.townshipcanada.com/autocomplete/legal-location?location=NW-2&proximity=-114.2312,51.2131' \
-H 'x-api-key: 1234567890abcdefghij'

Response with proximity parameter

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-114.228309197, 51.237681192]
      },
      "properties": {
        "shape": "centroid",
        "search_term": "NW-2",
        "legal_location": "NW-21-26-2-W5"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-114.251564546, 51.237667258]
      },
      "properties": {
        "shape": "centroid",
        "search_term": "NW-2",
        "legal_location": "NW-20-26-2-W5"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-114.20510579, 51.23767145]
      },
      "properties": {
        "shape": "centroid",
        "search_term": "NW-2",
        "legal_location": "NW-22-26-2-W5"
      }
    }
  ]
}

To illustrate the effectiveness of the proximity parameter, let's compare it with the response without using this parameter:

Response without proximity parameter

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-97.364023884, 49.011627951]
      },
      "properties": {
        "shape": "centroid",
        "search_term": "NW-2",
        "legal_location": "NW-2-1-1-E1"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-97.49879016, 49.011570727]
      },
      "properties": {
        "shape": "centroid",
        "search_term": "NW-2",
        "legal_location": "NW-2-1-1-W1"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-102.045408609, 49.009985497]
      },
      "properties": {
        "shape": "centroid",
        "search_term": "NW-2",
        "legal_location": "NW-2-1-1-W2"
      }
    }
  ]
}

Visualizing the difference

To further help your understanding, we've included a visual comparison: maps showing the response with and without the proximity parameter. These maps demonstrate the clear difference in search results, highlighting how the proximity parameter refines and localizes the search outcomes.

Map showing search results with the proximity parameter

Map showing search results with the proximity parameter

Map showing search results without the proximity parameter

Map showing search results without the proximity parameter

Get started

Visit our developer documentation for detailed information on pricing, API keys, and to access our quick-start guides. These guides provide you with step-by-step instructions on how to set up API keys and begin using our APIs effectively.

We can’t wait to see how you leverage this new feature in your applications. Happy coding!

Please note that the API key used in the example is for demonstration purposes only. Ensure you use your own API key in your requests.