Represent provides a REST API to a wealth of information about Canadian elected officials and electoral districts.
The base URL for all requests is http://represent.opennorth.ca.
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.
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.
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.
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.
We have a Node.js client library. If you’ve written a client library, contact represent@opennorth.ca to have it listed here.
Not required, but consider adding: District and politician data from <a href="http://represent.opennorth.ca/">Represent</a>
Please consult our privacy policy for any questions about the data we collect.
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.
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.
name or domainA 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.
name or external_idA 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.
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.
A representative is an elected official.
name, first_name, last_name, gender, district_name, elected_office or party_nameOnly 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 | ||
| 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 |
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.
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.