Represent provides a REST API to a wealth of information about Canadian elected officials and electoral districts.


Basics

The base URL for all requests is http://represent.opennorth.ca.

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

Search the database

You can filter resources with query string parameters. For example, to find representatives named “Rodney,” send a request to /representatives/?first_name=Rodney. Each resource below lists the fields you can filter on.

You can perform substring queries 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”, send a request to /representatives/?last_name__istartswith=m.

Control the output

All resources output JSON. For a user-friendly HTML version of the JSON response, add format=apibrowser to the query string. Add pretty=1 to just indent the raw JSON. We support JSONP for client-side cross-domain requests – just add a callback parameter to the query string.

Lists of resources are paginated. Under the meta field, the next field links to the next page, and previous links to the previous page (if available). total_count is the total number of items in the list. You can control the number of items returned by adding a limit parameter to the query string, and the start offset by adding an offset parameter.

Bulk downloads

To download all representatives, send a request to http://represent.opennorth.ca/representatives/?limit=1000 and follow the next link in meta section until you reach the end. We host the digital boundary files and postal codeOM concordances which we have permission to distribute on GitHub.

Rate limits

If you make more than 60 requests per minute, you may receive a HTTP 503 Service Unavailable error. Please contact represent@opennorth.ca if you expect high usage.

Client libraries

We have a Node.js client library. If you’ve written a client library, contact represent@opennorth.ca to have it listed here.

Attribution

Not required, but consider adding: District and politician data from <a href="http://represent.opennorth.ca/">Represent</a>

Privacy

Please consult our privacy policy for any questions about the data we collect.

Contributing

All our representative data comes from scrapers. If you’d like to improve our representative data, update our scrapers! Find the link to the scraper in the scraperwiki_url field of the representative set resource, make a copy of the scraper on ScraperWiki, edit your copy, then email represent@opennorth.ca. If you’d like to add a new representative set, use an existing scraper as an example.

Boundary Sets

A boundary set is a group of districts, like BC electoral districts or Toronto wards. Discover what boundary sets are available and get details on their source.

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

Boundaries

A boundary is a single district.

The external_id field (which is not always present) is a numerical ID used in the source shapefile to identify districts. The metadata field contains all attributes from the source shapefile; it is unmodified and may be out-of-date or erroneous.

To access spatial data, follow the links in the simple_shape_url, shape_url and centroid_url fields. simple_shape is the district’s shape simplified to a tolerance of 0.002, which looks fine and loads faster. The default output is GeoJSON. You may request KML or Well-Known Text by adding format=kml or format=wkt to the query string.

Get all boundaries
/boundaries/ Click to view JSON
Get the boundaries for one boundary set
/boundaries/toronto-wards/
Get the boundaries for multiple boundary sets (comma-separated)
/boundaries/?sets=toronto-wards,ottawa-wards
Get one boundary
/boundaries/nova-scotia-electoral-districts/cape-breton-north/
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 by name or external_id
/boundaries/?name=Niagara Falls
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

Postal codesOM

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

The boundaries_centroid field lists boundaries that contain the postal code’s center point (centroid), provided by Geocoder.ca. A centroid is a point, but a postal code is a shape (a set of points), 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 the boundaries_concordance field may list, for example, multiple Ontario electoral districts for a single postal code like K0A 1K0.

If you are searching for a specific boundary, you must check both boundaries_centroid and boundaries_concordance.

The response also has representatives_centroid and representatives_concordance fields that behave similarly.

If you are searching for a specific representative, check both representatives_centroid and representatives_concordance.

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

Postal CodeOM is an official mark of Canada Post Corporation.

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

Representative sets

A representative set is a group of elected officials, like the House of Commons or Toronto City Council. Discover what representative sets are available and get the URL to their scraper on ScraperWiki.

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

Representatives

A representative is an elected official.

Get all representatives
/representatives/ Click to view JSON
Get the representatives for one 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=edmonton-wards/ward-1,edmonton-wards/ward-2,edmonton-wards/ward-3
Find representatives by name, first_name, last_name, gender, district_name, elected_office or party_name
/representatives/house-of-commons/?last_name=Harper

Only the “required” fields below are always present in the response. You can improve the data we provide by updating our scrapers.

Field name Required? Example Notes
name Yes Stephen Harper
district_name Yes Calgary Southwest
elected_office Yes MP, MLA, Mayor, Councillor, Alderman Will be the same for all representatives at the federal and provincial levels
source_url Yes The URL at which the data is scraped May be the same as url below
first_name Stephen If you're writing a scraper, only set this field if the first name appears separately in the source. Don't parse it out yourself.
last_name Harper If you're writing a scraper, only set this field if the last name appears separately in the source. Don't parse it out yourself.
party_name Conservative
email example@example.com
url http://legislature.ca/stephen-harper This should generally be the URL to 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 ID provided alongside 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 JSON array with basic contact information for the representative's offices. It should be an array of JSON objects (hashes), with the optional keys: postal (mailing address), tel (telephone), fax (telephone), type (what kind of office this is, e.g. constituency or legislature).
extra { 'hair_colour': 'brown' } A JSON object with any extra data you think is worth collecting that doesn't fit in other fields

Elections

An election is an event with a date, tied to a group of electoral candidates.

This resource behaves like the representative sets resource; see that resource for additional example queries.

Do not rely on this endpoint for an authoritative list of elections in Canada.

Get all elections
/elections/ Click to view JSON

Candidates

A candidate is a person running for office in an election.

This resource behaves like the representative resource; see that resource for additional example queries.

Candidate lists may be incomplete or incorrect, given the frequency of changes and the unreliability of sources. Independent and small-party candidates are especially likely to be missing.

Get all candidates
/candidates/ Click to view JSON
Find candidates by latitude and longitude
/candidates/?point=48.4328,-123.3347