Download OpenAPI specification:
This API provides progammatic access to New Zealand legislation. It is currently "Version Zero" of an API, which has been developed to provide an opportunity for developers to test and provide feedback which will inform future enhancement and refinement.
The functionality of the API is intended to match that of the site search on the Legislation Website, and is strongly influenced by the FRBR model.
This API is based on a three-tier conceptual model of works, versions, and formats.
A work is the highest level, and represents the concept of an enduring standalone piece of legislation, that may have multiple versions. Each work has a work_id. Examples of works are:
act_public_1990_109bill_government_2022_186secondary-legislation_pco-drafted_1982_221One level below a work is a version. Each work can have one or more versions. Each consolidation of an Act is a new version, as is each stage of a Bill. A version is equivilant to an expression in the FRBR model. Each version has a version_id. Examples of versions are:
act_public_1990_109_en_2022-08-30bill_government_2022_186_en_2023-06-27secondary-legislation_pco-drafted_1982_221_en_2013-07-01One level below a version is a format. Each version of each work will have multiple formats, such as the source XML file, a PDF file, or an HTML page. Some versions will have formats that other versions don't have, such as the as enacted versions of some Acts which have also have a format providing a scan of the original printed Act. A format is equivilant to a manifestation in the FRBR model.
This API does not include an equivilant of the fourth level in the FRBR model, 'Item', which would generally be the concrete example of a specific format of a version, i.e. an XML file saved on a particular drive, or a PDF file printed on sheets of paper.
The structure of work_id and version_id identifiers used by this API is shared with the URLs of the Legislation website. They are constructed from six segments:
type — Kind of legislation. Must be one of: act, bill, secondary-legislation, amendment-paper.
subtype — Sub-classification of that type. Allowed values depend on type:
public, imperial, local, private, provincialgovernment, local, members, privateagency-drafted, pco-draftedgovernment, membersdate — Year. Must be four digits (YYYY). May be prefixed with ~ when the value is ephemeral.
number — Legislation number or identifier. Must match: digits. May have followed by a single letter (deduplication), optionally followed by a hyphen and letter (e.g. bill split: 96-B). May be prefixed with ~ when ephemeral.
language — Language. Currently only en is used.
version_date — Date identifying the version in time. Must be YYYY-MM-DD. May be prefixed with ~ when ephemeral. May have a suffix of one or more deduplication letters (e.g. A, B, AB, BA, 2023-12-31B) when multiple versions share the same base date.
A version_id is all six segments, and a work_id is the first four segments, each joined together with underscore characters.
For some agency-published secondary legislation harvested from agency websites through the pilot secondary legislation service, we do not have sufficient data to construct a permanent identifier. In these cases, we use fallback values to calculate 'ephemeral' identifiers.
For example, if we do not know the commencement date of a piece of secondary legislation, we cannot determine the correct value for the version_date segment, and will fall back to using the date the record was harvested from the agency website.
To indicate that these values are not final, and may change if we get better data for the record in the future, they are prefixed with a ~ character. Any identifiers which contain ~ characters may change in the future.
Website URLs for legislation follow the same pattern as the identifiers described above:
https://www.legislation.govt.nz/{type}/{subtype}/{date}/{number}/{language}/{version_date}/
The website uses latest as an alias value in the version_date segment, which always resolves to the most recent version of a work.
Responses to API queries include links to versions in their available formats. These can also be constructed directly by manipulating URLs, for example:
For legislation and secondary legislation drafted by the PCO; html, pdf, and xml formats are available.
For as enacted versions of pre-2008 Acts that have been converted from scans of the original printed volumes, an additional format of pdf_original_scan is available which contains the scanned PDF.
For agency drafted secondary legislation harvested through the pilot secondary legislation service, HTML or PDF formats may be available, but this will vary from record to record, and links may point to agency websites which do not follow the URL patterns described above.
Each API key has a default rate limit of 10,000 requests per day, with the quota resetting at midnight NZ local time.
Requests sent after this rate limit has been reached will receive a response with HTTP status code 429, Too Many Requests.
The rate limit is communicated using the X-RateLimit response headers, which have values of:
X-RateLimit-Limit: number of requests permitted per period.X-RateLimit-Remaining: number of requests remaining in the current period.X-RateLimit-Reset: Unix timestamp of the UTC time at which the period ends and the quota resets.In addition to these per-key rate limits, there is a burst limit of no more than 2,000 requests permitted from any single IP address in any five minute period. Requests sent after this limit is reached will receive a response with HTTP status code 403 Forbidden. Once a further five minutes have elapsed, further requests from that IP address will be permitted.
| api_key | string API Key for authentication (can also be passed via X-Api-Key header) |
| search_term | string Search term to filter results |
| search_field | string Field to search in (title or fulltext) |
| legislation_status | string Filter by legislation status |
| legislation_type | string Filter by legislation type |
| X-Api-Key | string API Key for authentication (can also be passed via api_key query parameter) |
Search for works.
This endpoint is the main entry to the API, and mirrors the functionality of the website site search. Searches can be either title or content searches, and results are a series of works that match the search query.
Each work has a latest_matching_version key with details of the newest version of the work that the search term was found within. This may not be the same version as the newest version of the work, for example if you perform a content search for a phrase that appears in an older version of an Act in a section which has since been repealed and does not appear in newer versions. Inside the latest_matching_version object is a key is_latest_version which gives a boolean value for whether the version described in latest_matching_version is the actually newest version of that work.
The work_id of each work returned can be passed to the /works/{work_id}/versions endpoint to get all versions of that work, and any version_id can be passed to the /versions/{version_id} endpoint to get details of that specific version.
| api_key | string API key for authentication. Can also be passed via |
| search_term | string What to search for. The supplied phrase will be searched in either work titles or work content depending on the value of the Stemming is enabled by default, i.e. 'levy' will return matches for both 'levy' and 'levies'. To disable stemming for a word or phrase, wrap it in " charcters. The search term is processed by ElasticSearch as a 'Simple query string query'. For full details on this syntax, see the ElasticSearch docs. |
| search_field | string Enum: "title" "content" Whether to perform a title search of content search. |
| page | integer Default: 1 Which page of results to receive, for responses where there are more results returned than the |
| per_page | integer Default: 20 How many results to receive in a single response. Default is |
| legislation_status | string Enum: "in_force" "not_in_force" "no_value" Filter to specific legislation status. |
| legislation_type | string Enum: "act" "amendment_paper" "bill" "secondary_legislation" Filter to a specific legislation type. |
| act_type | string Enum: "public" "private" "imperial" "local" "provincial" Filter to a specific type of Act. Should only be supplied if |
| act_classification | string Enum: "principal" "amendment" Filter to a specific classification of Act. Should only be supplied if |
| act_status | string Enum: "in_force" "not_in_force" "repealed" Filter to a specific status of an Act. Should only be supplied if |
| instrument_type_group | string Enum: "regulations" "order" "rules" "code" "bylaws" "determination" "exemption" "notice" "instrument" "other_type" Filter to a specific type of secondary legislation. Should only be supplied if |
| instrument_status | string Enum: "expired" "in_force" "not_yet_in_force" "revoked" "superseded" Filter to a specific status of secondary legislation. Should only be supplied if |
| instrument_classification | string Enum: "principal" "amendment" Filter to a specific classification of secondary legislation. Should only be supplied if |
| bill_type | string Enum: "government" "local" "member" "private" Filter to a specific type of Bill. Should only be supplied if |
| bill_status | string Enum: "current" "enacted" "terminated" Filter to a specific status of Bill. Should only be supplied if |
| administering_agencies | string Filter to a specific administering agency. The value must be the full text name, exactly as listed on the browse agencies page. |
| sort_by | string Enum: "title_asc" "title_desc" "year_asc" "year_desc" "most_recently_updated" How to sort the results. Options are:
|
| publisher | string Enum: "Agency" "Parliamentary Counsel Office" Filter to works published by PCO (all Acts, Bills, Amendment papers, and PCO-drafted secondary legislation) with a value of |
| X-Api-Key | string API key for authentication. Can also be passed via |
{- "results": [
- {
- "act_classification": "string",
- "act_status": "string",
- "act_type": "string",
- "bill_status": "string",
- "bill_type": "string",
- "instrument_classification": "string",
- "instrument_status": "string",
- "instrument_type_group": "string",
- "administering_agencies": [
- "string"
], - "latest_matching_version": {
- "title": "string",
- "version_id": "string",
- "is_latest_version": true,
- "formats": [
- {
- "type": "string",
- "url": "string"
}
]
}, - "work_id": "string",
- "legislation_status": "string",
- "legislation_type": "string"
}
], - "page": 0,
- "per_page": 0,
- "total": 0
}Get all versions of a specified work.
| work_id required | string The ID of the work to return versions of. |
| api_key | string API key for authentication. Can also be passed via |
| sort | string Default: "desc" Enum: "asc" "desc" How to sort the results. |
| X-Api-Key | string API key for authentication. Can also be passed via |
{- "results": [
- {
- "act_classification": "string",
- "act_status": "string",
- "act_type": "string",
- "bill_status": "string",
- "bill_type": "string",
- "instrument_classification": "string",
- "instrument_status": "string",
- "instrument_type_group": "string",
- "administering_agencies": [
- "string"
], - "title": "string",
- "version_id": "string",
- "formats": [
- {
- "type": "string",
- "url": "string"
}
], - "work_id": "string",
- "legislation_status": "string",
- "legislation_type": "string"
}
], - "page": 0,
- "per_page": 0,
- "total": 0
}Get details of a specific version of a work.
| version_id required | string |
| api_key | string API key for authentication. Can also be passed via |
| X-Api-Key | string API key for authentication. Can also be passed via |
{- "title": "string",
- "version_id": "string",
- "work_id": "string",
- "legislation_status": "string",
- "legislation_type": "string",
- "administering_agencies": [
- "string"
], - "act_type": "string",
- "act_status": "string",
- "instrument_type_group": "string",
- "instrument_status": "string",
- "instrument_classification": "string",
- "bill_type": "string",
- "bill_status": "string",
- "formats": [
- {
- "type": "string",
- "url": "string"
}
]
}