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.
The Government consultations listing, including:
- details for consultations from both central and local government
- listings sorted by topic, agency and status.
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.
Additional API features
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’).
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.
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.
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.
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.