Represent gives developers access to the largest database of electoral districts and elected official contact information in Canada.


Basics

The base URL is http://represent.opennorth.ca. All endpoints output JSON.

Heads up! Subscribe to our low-volume mailing list to be notified of API changes.

Paginate

Results are paginated 20 per page by default. Set the number of results per page by adding a limit query parameter. Paginate manually using the offset query parameter or, under the meta field, use the next and previous links to navigate to the next and previous pages (if any). Under the meta field, total_count is the number of results.

Filter results

Filter results with query parameters. To find representatives whose first name is “Rodney”, for example, request /representatives/?first_name=Rodney. Each endpoint below lists its filter fields.

Perform substring searches by appending __querytype to the parameter name, where querytype is one of iexact, contains, icontains, startswith, istartswith, endswith, iendswith or isnull. A leading i makes the match case-insensitive. For example, to find representatives whose last name starts with “M” or “m”, request /representatives/?last_name__istartswith=m.

Download in bulk

To download all representatives, send a request to http://represent.opennorth.ca/representatives/?limit=1000 and follow the next link in the meta section until you reach the end. We host the shapefiles and postal code concordances on GitHub.

Rate limits

Represent is free up to 60 requests per minute (86,400 queries/day). If you need to make more queries, contact us; otherwise, you may get HTTP 503 errors.

Debugging

For a browsable, HTML version of the JSON response, add a format=apibrowser query parameter. Add pretty=1 to just indent the raw JSON.

JSONP

We support JSONP for client-side cross-domain requests – just add a callback query parameter.

Libraries

Privacy policy

Postal codes

URLs should include the postal code in uppercase letters with no spaces.

The boundaries_centroid field lists boundaries that contain the postal code’s center point (centroid). A centroid is a point, but a postal code can be a line or polygon, so the list of boundaries in boundaries_centroid will sometimes be inaccurate.

The boundaries_concordance field lists boundaries linked to the postal code according to official government data. Postal codes can cross electoral districts, therefore boundaries_concordance may list multiple Ontario provincial districts for a single postal code like K0A 1K0, for example.

The response has representatives_centroid and representatives_concordance fields that behave similarly.

If you are searching for a specific boundary or representative, you must check both the centroid and concordance fields.

In most cases, the city, province and centroid fields will be non-empty.

To see what data is available, consult the list of boundary and representative sets. Are we missing information that you need? Contact us so that we can make it a priority.

Find boundaries and representatives by postal code
/postcodes/L5G4L3/ Click to view JSON
Find boundaries and representatives by postal code, limiting results to a specific boundary set
/postcodes/L5G4L3/?sets=federal-electoral-districts

Boundary Sets

A boundary set is a group of electoral districts, like BC provincial districts or Toronto wards.

Do we not have a set of boundaries that you need? Contact us so that we can make it a priority.

Get one page of boundary sets
/boundary-sets/ Click to view JSON
Get one boundary set
/boundary-sets/federal-electoral-districts/
Filter boundary sets by name or domain
/boundary-sets/?domain=Canada

Boundaries

If you want to draw boundaries, we recommend the simple_shape endpoint, which simplifies the shape to a tolerance of 0.002, looks fine and loads fast.

The default geospatial output format is GeoJSON. Add a format=kml or format=wkt query parameter to get KML or Well-Known Text instead.

The external_id field (not always present) is the boundary's machine identifier. The metadata field contains all attributes from the source shapefile; it is unmodified and may be out-of-date or erroneous.

Get one page of boundaries
/boundaries/ Click to view JSON
Get one page of boundaries from a boundary set
/boundaries/toronto-wards/
Get one page of boundaries from multiple boundary sets (comma-separated)
/boundaries/?sets=toronto-wards,ottawa-wards
Get all simple shapes from a boundary set
/boundaries/toronto-wards/simple_shape
Get all original shapes from a boundary set
/boundaries/toronto-wards/shape
Get all centroids from a boundary set
/boundaries/toronto-wards/centroid
Get one boundary
/boundaries/nova-scotia-electoral-districts/cape-breton-centre/
Get one boundary's simple shape
/boundaries/nova-scotia-electoral-districts/cape-breton-centre/simple_shape
Get one boundary's original shape
/boundaries/nova-scotia-electoral-districts/cape-breton-centre/shape
Get one boundary's centroid
/boundaries/nova-scotia-electoral-districts/cape-breton-centre/centroid
Get the representatives for one boundary
/boundaries/toronto-wards/etobicoke-north-1/representatives/
Find boundaries by latitude and longitude
/boundaries/?contains=45.524,-73.596
Find boundaries that touch
/boundaries/?touches=alberta-electoral-districts/highwood
Find boundaries that intersect (“covers or overlaps” in PostGIS lingo)
/boundaries/?intersects=alberta-electoral-districts/highwood
Filter boundaries by name or external_id
/boundaries/?name=Niagara Falls

Representative sets

A representative set is a group of elected officials, like the House of Commons or Toronto City Council.

Do we not have a set of representatives that you need? Contact us so that we can make it a priority.

Get one page of representative sets
/representative-sets/ Click to view JSON
Get one representative set
/representative-sets/ontario-legislature/

Representatives

Get one page of representatives
/representatives/ Click to view JSON
Get one page of representatives from a representative set
/representatives/house-of-commons/
Find representatives by latitude and longitude
/representatives/?point=45.524,-73.596
Find representatives by boundary (comma-separated)
/representatives/?districts=calgary-wards/ward-1,calgary-wards/ward-2,calgary-wards/ward-3
Filter representatives by name, first_name, last_name, gender, district_name, elected_office or party_name
/representatives/house-of-commons/?last_name=Harper

Only the bold fields are present in all responses:

Field Example Notes
name Stephen Harper
district_name Calgary Southwest
elected_office MP, MLA, Mayor, Councillor, Alderman
source_url The URL at which the data is scraped May be the same as url below
first_name Stephen
last_name Harper
party_name Conservative
email example@example.com
url http://legislature.ca/stephen-harper The representative’s page on the official legislature site
photo_url http://legislature.ca/stephen-harper.jpg
personal_url http://stephenharper.blogspot.com/ A site run by the representative that’s not on the official legislature site
district_id 24013 If there’s an identifier besides the district name
gender M, F
offices [ {"postal": "10 North Pole, H0H 0H0", "tel": "555-555-5555", "type": "constituency"}, {"tel": "444-444-4444", "type": "legislature"} ] A list of objects with contact information for the representative’s offices. The keys are: postal (mailing address), tel (telephone), fax (facsimile), type (what kind of office this is, e.g. constituency or legislature).
extra { "hair_colour": "brown" } Any extra data

Elections

This endpoint behaves like the /representative-sets/ endpoint. See its documentation for more examples.

If you would like to add an election to Represent, contact us.

Get one page of elections
/elections/ Click to view JSON

Electoral candidates

This endpoint behaves like the /representatives/ endpoint. See its documentation for more examples.

Candidate lists may be incomplete or incorrect, as this information changes frequently.

If you would like to add candidates to Represent, contact us.

Get one page of candidates
/candidates/ Click to view JSON