Represent Civic Information API

Represent Civic Information API

Data Access

Find the elected officials and electoral districts for any Canadian address or postal code, at all levels of government

Visit API

πŸ“š Documentation & Examples

Everything you need to integrate with Represent Civic Information API

πŸš€ Quick Start Examples

Represent Civic Information API Javascript Examplejavascript
// Represent Civic Information API API Example
const response = await fetch('https://represent.opennorth.ca/', {
    method: 'GET',
    headers: {
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log(data);

Explore Canada's OpenNorth Represent API

The OpenNorth Represent API is a public web service that provides Canadian government data in a standardized and accessible format. By using this API, you can access data from a variety of sources, including federal, provincial, and municipal government websites.

Here's how to get started exploring Canada's OpenNorth Represent API using JavaScript:

Step 1: Register for an API key

Before you can start using the OpenNorth Represent API, you'll need to register for an API key. This key will allow you to access the data on the Represent website. You can register for an API key here.

Step 2: Make API requests

Now that you have your API key, you can start making requests to the Represent API. The API has a number of endpoints that you can access, including:

  • Postal codes
  • Electoral districts
  • Representatives
  • Political parties

Here is an example of how to access the postal codes endpoint using the JavaScript fetch API:

const apiKey = 'your_api_key_here';
const postalCode = 'K1A0A4';

fetch(`https://represent.opennorth.ca/postcodes/${postalCode}/?sets=federal-electoral-districts&key=${apiKey}`)
  .then(response => response.json())
  .then(data => console.log(data));

This example fetches data for the postal code K1A0A4 and includes data for federal electoral districts. Notice that you need to include your API key in the request URL using the key parameter.

Step 3: Parse API responses

Once you've made a request to the OpenNorth Represent API, you'll receive a response containing the data you requested. The response will be in JSON format, which means you can parse it into a JavaScript object using the JSON.parse() method.

Here's an example of how to parse the response from the previous example:

const apiKey = 'your_api_key_here';
const postalCode = 'K1A0A4';

fetch(`https://represent.opennorth.ca/postcodes/${postalCode}/?sets=federal-electoral-districts&key=${apiKey}`)
  .then(response => response.json())
  .then(data => {
    const districts = data['representatives_centroid'];
    districts.forEach(district => {
      console.log(district.name);
    });
  });

This example parses the response and then iterates over the federal electoral districts in the response, logging the name of each district to the console.

Conclusion

That's it! This short guide should help you get started exploring Canada's OpenNorth Represent API using JavaScript. Remember to read the API documentation carefully to ensure you're making proper requests and parsing responses correctly. Happy exploring!

πŸ“Š 30-Day Uptime History

Daily uptime tracking showing online vs offline minutes

Jun 3Jun 5Jun 7Jun 9Jun 11Jun 13Jun 15Jun 17Jun 19Jun 21Jun 23Jun 25Jun 27Jun 29Jul 204008001440Minutes
Online
Offline

Related APIs in Data Access