Skip to main content

Similar Neighborhoods

Stable
English and FrenchUS 🇺🇸 and Canada 🇨🇦

Query similar neighborhoods based on Local Logic scores and demographics features.

When backend configuration is provided, the results are limited by the configuration so that the similar neighborhoods returned can be restricted to those relevant for those using the endpoint. The backend configuration will also pass links and thumbnail URLs in the response and to power the SDK.

Calculating Neighborhood Similarity

The neighborhoods returned by Similar Neighborhoods (or displayed on the NeighborhoodMatchSDK) are those with the highest similarity scores that are either

  • within the metro area of the source neighborhood, when it falls into a defined metro area
  • within 100 kilometers, when the source neighborhood is not within a defined metro area

For neighborhood similarity, the calculation is based on both demographics data and Local Logic Location Scores:

  • Demographics
    • Population density
    • Households with children
    • Type of housing
    • Number of bedrooms
  • Local Logic Location Scores:
    • Transportation: Transit-friendly, Pedestrian-friendly, Car-friendly
    • Services: Groceries, Restaurants, Cafés, Shopping, Nightlife
    • Character: Vibrancy, Quiet
    • Education: Schools, Daycares

GET v3/similar-neighborhoods/{geog_id}

Accepted values for geog_id are g10_*, g20_* and g30_*. Other values will result with a 404 (not found) status code.

GET v3/similar-neighborhoods/{geog_id}

This API uses JWT token based authentication. This JWT Bearer token is what is used to populate the Authorization header below.

Instructions on how to retrieve this token can be found at Getting Started.

HeaderStatusDescription
AuthorizationrequiredYour bearer token retrieved from our authorization API, ex. Bearer eyJhbGci...
AcceptrequiredThe datatype to request, this API will return application/json.

QueryString

ParameterStatusDescription
languageoptionalThe language in which to return the neighborhood names.
Accepted values: en, fr
Default: en
limitoptionalHow many items to return, at most, under the most_similar key.
Maximum: 10
Default: 5
config_keyoptionalOverride the client configuration to use. Set as an empty string to not use any configuration.

Usage examples

  require('node-fetch')('https://api.locallogic.co/v3/similar-neighborhoods/g20_f25dyhf3"?' + new URLSearchParams({
}), {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: 'Bearer eyJhbGciOiJ...'
}
})
.then(response => response.json())
.then(body => {
console.log(body)
})
.catch(error => {
console.log(error)
})

Response example

{
"data": {
"affordability": {
"apartments": {
"median_price": {
"currency": "USD",
"value": 387500.0
},
"raw_count": 57,
"weight": 0.11067961165048544
},
"houses": {
"median_price": {
"currency": "USD",
"value": 555000.0
},
"raw_count": 454,
"weight": 0.8815533980582524
},
"plexes": {
"median_price": {
"currency": "USD",
"value": 565920.0
},
"raw_count": 4,
"weight": 0.007766990291262136
}
},
"features": {
"households_with_children_percent": 12.549591126224591,
"population_density_km2": 0.41453746470034947,
"residents_apartments_percent": 0.0,
"residents_detatched_homes_percent": 77.55555555555556
},
"id": "g30_c28wnknk",
"most_similar": [
{
"affordability": {
"apartments": {
"median_price": {
"currency": "USD",
"value": 450000.0
},
"raw_count": 5,
"weight": 0.03067484662576687
},
"houses": {
"median_price": {
"currency": "USD",
"value": 350000.0
},
"raw_count": 158,
"weight": 0.9693251533742331
}
},
"centroid_distance_m": 24113,
"features": {
"households_with_children_percent": 19.593207688001492,
"population_density_km2": 0.3353790106818646,
"residents_apartments_percent": 0.0,
"residents_detatched_homes_percent": 89.13043478260869
},
"id": "g30_c28qxy01",
"name": "Point Roberts",
"scores": {
"car_friendly": 4.3151941862,
"groceries": 1.8888078633,
"pedestrian_friendly": 1.4768063996,
"quiet": 4.8382682385,
"restaurants": 1.9029849732
},
"similarity": 0.77446127
},
{
"affordability": {
"apartments": {
"median_price": {
"currency": "USD",
"value": 359900.0
},
"raw_count": 39,
"weight": 0.11079545454545454
},
"houses": {
"median_price": {
"currency": "USD",
"value": 562000.0
},
"raw_count": 313,
"weight": 0.8892045454545454
}
},
"centroid_distance_m": 36593,
"features": {
"households_with_children_percent": 29.85303123086344,
"population_density_km2": 0.6702550482305127,
"residents_apartments_percent": 5.66552755139866,
"residents_detatched_homes_percent": 93.68314801174228
},
"id": "g30_c29j0hed",
"name": "Sudden Valley",
"scores": {
"car_friendly": 4.6026688494,
"groceries": 0.0,
"pedestrian_friendly": 0.5148334311,
"quiet": 4.5573567538,
"restaurants": 0.9099096404
},
"similarity": 0.70634484
},
{
"affordability": {
"houses": {
"median_price": {
"currency": "USD",
"value": 1300000.0
},
"raw_count": 63,
"weight": 1.0
}
},
"centroid_distance_m": 27746,
"features": {
"households_with_children_percent": 25.70806100217865,
"population_density_km2": 0.34775378671541324,
"residents_apartments_percent": 0.0,
"residents_detatched_homes_percent": 100.0
},
"id": "g10_c28vh68v",
"name": "Edgemoor",
"scores": {
"car_friendly": 4.5486872212,
"groceries": 1.9398932457,
"pedestrian_friendly": 1.4222025882,
"quiet": 4.0891983428,
"restaurants": 1.7360640973
},
"similarity": 0.61963063
},
{
"affordability": {
"houses": {
"median_price": {
"currency": "USD",
"value": 475000.0
},
"raw_count": 7,
"weight": 1.0
}
},
"centroid_distance_m": 9431,
"features": {
"households_with_children_percent": 21.15655853314527,
"population_density_km2": 0.041122106110206724,
"residents_apartments_percent": 0.5641748942172,
"residents_detatched_homes_percent": 84.0620592383639
},
"id": "g30_c28y3286",
"name": "Custer",
"scores": {
"car_friendly": 4.9957842605,
"groceries": 0.0,
"pedestrian_friendly": 0.5,
"quiet": 3.4902238824,
"restaurants": 1.0282611011
},
"similarity": 0.60772216
},
{
"affordability": {
"houses": {
"median_price": {
"currency": "USD",
"value": 843736.0
},
"raw_count": 62,
"weight": 1.0
}
},
"centroid_distance_m": 30612,
"features": {
"households_with_children_percent": 25.26439482961222,
"population_density_km2": 0.4504609472887251,
"residents_apartments_percent": 0.0,
"residents_detatched_homes_percent": 84.86486486486487
},
"id": "g30_c28vq9c3",
"name": "Geneva",
"scores": {
"car_friendly": 4.5724320643,
"groceries": 1.3256155278,
"pedestrian_friendly": 0.9877577208,
"quiet": 4.1801797775,
"restaurants": 0.681860721
},
"similarity": 0.5479913
}
],
"name": "Birch Bay",
"scores": {
"car_friendly": 4.8927266271,
"groceries": 1.0325627363,
"pedestrian_friendly": 0.5975533574,
"quiet": 3.8888749441,
"restaurants": 0.8921594214
}
},
"meta": {
"message": "Successfully called v3/similar-neighborhoods API. No client configuration was applied. This is a Beta endpoint. Its interface can change without notice.",
"statusCode": 200,
"type": "LocalLogic.API.Success"
}
}

SDK Implementations

Similar Neighborhoods is used by one Local Logic SDK:

SDKDescription
NeighborhoodMatch SDKRetrieve the configured client-specific neighborhoods with the highest similarity to the given neighborhood.

Error codes

When calling Local Logic’s API, you may receive an HTTP error code. These errors are explained below. In general, error codes starting with “4” are due to an invalid API call and can be fixed on your end, whereas error codes starting with “5” are due to server errors (that is, problems on our end). If you receive something not described here, please contact us at support@locallogic.co.

400 - BadRequest

This error code happens when the request inputs are incorrect. Use the detail field of the response for clarification. Example:

{
"code": "LocalLogic.API.BadRequest",
"detail": "ValidationErrors: AroundEndpoint is invalid:\n\tinclude is invalid: \"bad_input\" is not an acceptable value: \"groceries\", \"restaurants\", \"nightlife\", \"cafes\", \"shopping\", \"daycares\", \"primary_schools\", \"high_schools\""
}

401 - Unauthorized

This error code happens when your API key cannot access specific resources or locations. For example, some API keys can only access certain countries / states / provinces. Feel free to contact us for more information. Example:

{
"code": "LocalLogic.API.Unauthorized",
"detail": "Your API KEY doesn't support this region"
}

403 - Forbidden

This error code happens when you forgot to include security credentials with your request or you are requesting a parameter that you do not have access to. Example:

{
"message": "Forbidden"
}

404 - NotFound

This error code happens when we don’t have data for the requested location. For example, if you send a lat/lng pair for a location in Antarctica, we will return this error as we don’t have data for Antarctica (yet!). Example:

{
"code": "LocalLogic.API.NotFound",
"detail": "No Location Scores found for this location."
}

422 - Unprocessable Entity

This error code is returned when the correct parameters have been sent however, the data they contain is not valid. For example, if you send a lat/lng pair and the latitude is invalid (ie. not in the range [-90, 90]) and/or the longitude is invalid (ie. not in the range [-180, 180]).

{
"message": "Latitude must be within [-90, 90], Longitude must be within [-180, 180], Requires at least lat/lng pair, or geography_ids. None supplied.",
"code": "LocalLogic.API.BadRequest",
"statusCode": 422
}

500 - ServerError

This error code means that an error occurred on our end. Feel free to retry the same request to see if the problem persists. If you received a lot of these errors, please contact us at support@locallogic.co Example:

{
"code": "LocalLogic.API.ServerError",
"detail": "No Location Scores found for this location."
}

502 - BadGateway

This error code means that an error came from our cloud provider. Feel free to retry the same request to see if the problem persists. Example:

{
"message": "Internal server error"
}