Information about the population living around a given location or in a defined area can be retrieved using the v3/demographics
endpoint. The data returned describes a wide range of demographic variables, organized by categories. All populated areas in Canada and the US (50 states + District of Columbia) are covered.
GET v3/demographics
Country | Source |
---|---|
Canada | Census 2021 |
USA | American Community Survey 2021 |
Type | Canada | USA |
---|---|---|
Household Income | ✅ | ✅ |
Individual income | ✅ | · |
Commute mode | ✅ | ✅ |
Household composition | ✅ | ✅ |
Population age | ✅ | ✅ |
Housing tenancy | ✅ | ✅ |
Language knowledge | ✅ | · |
Education | ✅ | ✅ |
Housing type | ✅ | ✅ |
Mother tongue | ✅ | · |
Employment status | . | ✅ |
Children per Household | ✅ | · |
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 Accessing the API → V3 API Authorization.
Header | Status | Description |
---|---|---|
Authorization | required | Your bearer token retrieved from our authorization API, ex. Bearer eyJhbGci... |
Accept | required | The datatype to request, this API will return application/json . |
The region to be queried by the endpoint can be defined two ways: (1) by specifying a lat
/lng
coordinate, with optional radius
/radius_unit
parameters, (2) or by providing a polygon
parameter.
When using the lat
/lng
coordinate query method without specifying radius
/radius_unit
parameters, the endpoint will return data for residents living within a five minute walk of the coordinate. When including radius
/radius_unit
parameters, the resulting circular area around the lat
/lng
coordinate will be queried. radius_unit
can be either meter
or mile
.
When using the polygon
query method, the demographic data returned will cover residents of the region defined by the polygon area. Polygons are specified using the WKT format. The only accepted type is POLYGON
, and holes are not supported. Each polygon point must be defined as a lng
/lat
coordinate.
API Limitations
Warning
Parameter | Status | Description |
---|---|---|
lat | optional | A decimal number between -90 and 90 (Latitude) |
lng | optional | A decimal number between -180 and 180 (Longitude) |
radius | optional | A positive float number (Circle radius) |
radius_unit | optional | The unit type of the radius. Available: meter , mile . Default: meter |
polygon | optional | List of 2D lng/lat points that define a 2D polygon, using the WKT representation |
language | optional | The language that demographic variable labels will be returned in. Available: en , fr . Default: en |
lat
/lng
parametersrequire('node-fetch')('https://api.locallogic.co/v3/demographics?' + new URLSearchParams({lat: 41.847206,lng: -87.668825,language: 'en',}), {method: 'GET',headers: {Accept: 'application/json',Authorization: 'Bearer eyJhbGciOiJ...'}}).then(response => response.json()).then(body => {console.log(body)}).catch(error => {console.log(error)})
lat
/lng
and radius
/radius_unit
parametersimport requestsresponse = requests.get("https://api.locallogic.co/v3/demographics",headers={"Accept": "application/json","Authorization": "Bearer eyJhbGciOiJ..."},params={"lat": 45.5017,"lng": -73.5656,"radius": 500,"radius_unit": "meter","lang": "en"})print(response.json())# See response example below
polygon
parameterimport requestsresponse = requests.get("https://api.locallogic.co/v3/demographics",headers={"Accept": "application/json","Authorization": "Bearer eyJhbGciOiJ..."},params={"polygon": ("POLYGON((""-73.599092 45.528410, ""-73.596265 45.528433, ""-73.599123 45.527344, ""-73.599092 45.528410))")})print(response.json())# See response example below
{"data": {"type": "demographics","attributes": {"income": {"label": "Income","type": "standalone","variables": [{"variable": "avg_household_income","value": 88555.1858,"label": "Average household income"},{"variable": "avg_individual_income","value": 39706.2035,"label": "Average individual income"}]},"commute_mode": {"label": "Commute mode","type": "percent","variables": [{"variable": "transit","value": 0.3483,"label": "Public transit"},{"variable": "foot","value": 0.271,"label": "Foot"},{"variable": "bicycle","value": 0.115,"label": "Bicycle"},{"variable": "drive","value": 0.2339,"label": "Car"},{"variable": "other","value": 0.0318,"label": "Other"}]}}}}
In the above example of returned data, there are two categories of demographic data (“Income” and “Commute mode”). These categories have the following fields:
label
type: which can be either of the following:
percent
: this category’s variables are directly related; their values are percentages and theoretically should add up to 1.0 (100%). In practice, values may not add to 100% in all cases due to rounding.standalone
: this category’s variables are separate valuesvariables: A list of several variables for the category, each with the following:
variable
, a programmatic key that will be constant regardless of languagevalue
, the actual demographic valuelabel
, a language-specific description which can be used for display purposesIn the above example:
The average household income of the surrounding area is $88,555The average individual income is $39,70634.8% of people commute by transit27.1% of people commute by foot11.5% of people commute by bicycle23.4% of people commute by car3.2% of people commute by other modes
GET v2/demographics
Country | Source |
---|---|
Canada | Census 2016 |
USA | American Community Survey 2021 |
Type | Canada | USA |
---|---|---|
Household Income | ✅ | ✅ |
Individual income | ✅ | · |
Commute mode | ✅ | ✅ |
Household composition | ✅ | ✅ |
Population age | ✅ | ✅ |
Housing tenancy | ✅ | ✅ |
Language knowledge | ✅ | · |
Education | ✅ | ✅ |
Housing type | ✅ | ✅ |
Family composition | ✅ | · |
Mother tongue | ✅ | · |
Parameter | Status | Description |
---|---|---|
lat | required | A decimal number between -90 and 90 (Latitude) |
lng | required | A decimal number between -180 and 180 (Longitude) |
key | required | The API Key provided for you |
lang | optional | The language that demographic variable labels will be returned in. Available: en , fr . Default: en |
require('request')({method: 'GET',url: 'https://api.locallogic.co/v2/demographics', // note the v2qs: {lat: 45.5017,lng: -73.5656,key: 'YOUR_API_KEY'}}, function (err, response, body) {// See response example})
{"data": {"type": "Demographics","attributes": {"income": {"label": "Income","type": "standalone","variables": [{"variable": "avg_household_income","value": 88555.1858,"label": "Average household income"},{"variable": "avg_individual_income","value": 39706.2035,"label": "Average individual income"}]},"commute_mode": {"label": "Commute mode","type": "percent","variables": [{"variable": "transit","value": 0.3483,"label": "Public transit"},{"variable": "foot","value": 0.271,"label": "Foot"},{"variable": "bicycle","value": 0.115,"label": "Bicycle"},{"variable": "drive","value": 0.2339,"label": "Car"},{"variable": "other","value": 0.0318,"label": "Other"}]}}}}
In the above example of returned data, there are two categories of demographic data (“Income” and “Commute mode”). These categories have the following fields:
label
type: which can be either of the following:
percent
: this category’s variables are directly related; their values are percentages and theoretically should add up to 1.0 (100%). In practice, values may not add to 100% in all cases due to rounding.standalone
: this category’s variables are separate valuesvariables: A list of several variables for the category, each with the following:
variable
, a programmatic key that will be constant regardless of languagevalue
, the actual demographic valuelabel
, a language-specific description which can be used for display purposesIn the above example:
The average household income of the surrounding area is $88,555The average individual income is $39,70634.8% of people commute by transit27.1% of people commute by foot11.5% of people commute by bicycle23.4% of people commute by car3.2% of people commute by other modes