Open Data Catalogue for Developers

The Open Data Publisher is a two part application for browsing and querying open data from the City of Nanaimo. The Data Catalogue is set up for browsing through the available data sets and viewing external download links. The Data Api which provides to the data to the Catalogue and is open for use to the public. The api provides a queryable interface to access the City of Nanaimo's open data in a variety of formats described below.

Querying Open Data Publisher Data Service

The Open Data Publisher (ODP) data service exposes data through REST Web services. The basic format of an ODP service call is http://host/v1/container/dataset?query, where:

  • container is the name of the container (container is currently "sql").
  • dataset is the name of the data set (for example, "BusinessLicences" for the Business Licence data set in the Nanaimo container).
  • query is your set of query parameters, expressed using a subset of the WCF Data Services query syntax.

Note that ODP currently only supports the $filter and $top query options in the WCF Data Services query syntax. Example queries using the Crime Incidents data set are available on the Data Browser page of our Interactive SDK.

Also note that if a property has a null value for a particular entity in the data set, it will be omitted entirely from the result set returned by ODP. For example, in the Crime Incidents data set, the "method" property is only returned for records that have a "method" value in the underlying data set. Your application design should take this into account and handle potentially missing properties.

Most of our datasets are currently download only such as city-owned Fiber or Roads. We are working on providing more datasets with an api connection available like the Business Licence and Fire and Rescue Incident Response datasets.

Data Formats

AtomPub

By default, ODP returns data in the Open Data Protocol (OData) format. This format extends the broadly adopted Atom Publishing Protocol and can be easily consumed by a variety of platforms, including Microsoft .NET, Java, Ruby, PHP, and Python. Refer to the code samples on the Data Browser page for examples.

JSON

ODP can also return data in the JavaScript Object Notation (JSON) format, which can be conveniently consumed using JavaScript and other technologies. To return data in JSON format, simply append the format=json parameter to your query. Example:

http://api.nanaimo.ca/dataservice/v1/sql/BusinessLicences/?$filter=NAICSCategory%20eq%20'A5400'&format=json

JSONP

To mitigate security vulnerabilities associated with cross-site scripting attacks, Web browsers generally prevent client-side JavaScript applications originating in one network domain (for example, yourdomain.com) from making HTTP requests to other network domains (for example, ºome other network domain that hosts the ODP data services). This can prevent JavaScript applications hosted in another domain from making straight-forward calls to the ODP data services, but there a variety of techniques that can be used, such as this widely-used IFRAMES-based technique described by Michael Mahemoff.

ODP's data services also provide direct support for the JSONP technique. Using this technique, ODP's data services will call a callback function that you specify, passing in the results of your query in JSON format as an input format. To use this technique, issue a query with the following additional parameters: format=json&callback=yourCallback, where yourCallback is the name of a JavaScript callback function defined on the Web page issuing the request.

Refer to the JavaScript sample on the Data Browser page for an example of using JSONP with ODP. In that sample, the AdditionalDataLoaded() function is the JSONP callback function.

Geospatial Data

Many of the data sets in ODP also include geospatial data, which is returned in the Keyhole Markup Language (KML) format. This format is compatible with popular desktop and Web-based mapping technologies including Google Maps and Google Earth.

To return geospatial data in KML format, append the format=kml parameter to your query. Example:

http://api.nanaimo.ca/dataservice/v1/sql/BusinessLicences/?$filter=NAICSCategory eq 'A5400'&format=kml

Note that if the data set that you are using does not include any geospatial data, a KML query to ODP will return an empty result set.

Client Libraries

Developers using Microsoft Visual Studio 2008, Service Pack 1 (or later) can use WCF Data Services to access data from ODP through easy-to-use .NET classes. Within Visual Studio, this is accomplished by using the Add Service Reference feature (see .NET samples on the Data Browser page). To make accessing ODP data easier, Java developers can use Restlet Extension for WCF Data Services. PHP developers can take advantage of the Toolkit forToolkit for PHP with WCF Data Services.

Open Source

Open Data Publisher is a fork of Microsoft's OGDI project, rewritten to easily publish information from Microsoft SQL Server tables and views using the OData protocol, KML, and JSON. Feel free to download the Open Data Publisher source code from Codeplex.

Last updated: June 9, 2017

Help us improve our website

Don't include private or financial information in this form.