Skip to main content
Note:

For everything you need to know about COVID-19, go to covid19.govt.nz

Unite against COVID-19

Re-using Govt.nz content and data

The Govt.nz API (application programming interface) is available for anyone who wants to reuse content from Govt.nz. It lets you access Govt.nz data on demand, in a format that makes the data easy to re-use.

Content included in the API

The Government A to Z listings, including:

  • the contact details for government organisations
  • the contact details for non-government organisations that deliver government services
  • the names and portfolios of responsible Ministers, Chief Executives and Chairs.

Government A-Z

The Government consultations listing, including:

  • details for consultations from both central and local government
  • listings sorted by topic, agency and status.

Government consultations listing

Benefits of using an API

APIs are about transparency and openness which is how Govt.nz operates. An API:

  • saves time — updated information is available through the API automatically
  • helps to make information more reliable as it managed from one source 
  • makes it possible to share information through many sources in a consistent way.

If you’ve got ideas on how we can improve the API, send us your feedback.

Feedback

Additional API features

alllimit/offset

alllimit/offset

By default, all API responses contain at most the first 20 matching records. The first section in each response details the total number of available records plus the offset and count for this response. You can use this information to set an ‘offset’ query parameter and page through the available records. You can also use a ‘limit’ query parameter to return a different number of records (or set it to ‘all’).

Examples

https://www.govt.nz/api/v2/consultation/list?limit=all

https://www.govt.nz/api/v2/consultation/list?limit=40&offset=40

sort

sort

You can sort responses using multiple comma-separated fields. Field names preceded by a minus sign are sorted in descending order — a preceding plus sign is optional for ascending sorts.

Examples

https://www.govt.nz/api/v2/organisation/list?sort=name

https://www.govt.nz/api/v2/organisation/list?sort=-parent,+id

case

case

By default, the API uses camelCase (‘camel’), but you can specify snake_case (‘snake’) as a query parameter if you wish. If you use snake, your response fields:

  • will be returned in snake_case, and
  • you must use snake_case for other parameter names.

Specifying case=snake won’t change a lot of things, as the API tries to use simple one word field names which are the same in both case options.

Examples

https://www.govt.nz/api/v2/consultation/topic?case=snake&edited_since=2015-06-01T00:00:00+12:00

https://www.govt.nz/api/v2/consultation/topic?editedSince=2015-06-01T00:00:00+12:00

json/xml

json/xml

Our API returns data in JSON format by default. The Swagger interface has a format selector which populates each request’s Accept header with ‘application/json’ or ‘application/xml’. If you’re making requests programmatically you can use the same technique. If you prefer, you can add an extension to the URL instead — we’ll accept either method. Note that the extension sits at the end of the URL, not the end of the query parameters.

Examples

https://www.govt.nz/api/v2/organisation/914.xml?fields=addresses,contacts

https://www.govt.nz/api/v2/organisation/914.json?fields=names

Explore our API with Swagger

The Swagger interface requires a modern web browser.
It is not available for IE8 or IE9, and is not fully functional in IE10 or older versions of other browsers.