API

Working with the OpenGov NSW API

OpenGov NSW data and functionality are available via an open web API. This service provides additional options for agencies wishing to integrate OpenGov NSW with their own websites. It also means that external developers, and members of the public more broadly, can easily extract and use OpenGov NSW data.

Please note that OpenGov NSW content is licensed Attribution (CC BY) under the Creative Commons licensing system, unless otherwise indicated. Copyright resides with the State of New South Wales unless otherwise indicated.

The OpenGov NSW web API is being actively developed. Unfortunately this does mean that it may change over the coming months. On the positive side, we will be very receptive, and grateful, for any feedback or suggestions for improvements: opengov@records.nsw.gov.au

Search for publications

https://www.opengov.nsw.gov.au/search.xml?query=query term

- query: mandatory
- size: optional, default to 10
- page: optional, default to 1

Returns search results in the OpenSearch XML format (http://www.opensearch.org)

List all publications

https://www.opengov.nsw.gov.au/publications
or, https://www.opengov.nsw.gov.au/publications/all.json

- size: optional
- page: optional
- callback: optional, JSONP callback
- lastUpdatedDate: optional, all published since the specified date

Returns a JSON list of all publications on the site.

Information about publications comprises descriptive metadata and a list of publication files. Publication files are the sequence of files that make up a publication: while many publications are associated with just one file, others, including annual reports published in separate parts, have multiple files.

For example:

{
  "id": 11305,
  "title": "NSW Department of Commerce Annual Report 2007/08",
  "agencies": [
    "NSW Department of Commerce"
  ],
  "type": "Annual Report",
  "date": "2008",
  "publishers": [],
  "keywords": [
    "annual"
  ],
  "description": "",
  "language": "English",
  "coverage": "New South Wales",
  "copyright": "State of New South Wales",
  "files": [
    "https://www.opengov.nsw.gov.au/publication/12304",
    "https://www.opengov.nsw.gov.au/publication/12305",
    "https://www.opengov.nsw.gov.au/publication/12306",
    "https://www.opengov.nsw.gov.au/publication/12307",
    "https://www.opengov.nsw.gov.au/publication/12308",
    "https://www.opengov.nsw.gov.au/publication/12309",
    "https://www.opengov.nsw.gov.au/publication/12310",
    "https://www.opengov.nsw.gov.au/publication/12311"
  ]
}

List all publications created by a particular agency

https://www.opengov.nsw.gov.au/agencies/{agency id}.json

Returns a JSON list of all publications created by a particular agency.

List all active agencies

https://www.opengov.nsw.gov.au/agencies.json

Returns a JSON list of all NSW government agencies with publications on the site.

Information includes agency id, agency name, and, optionally, a link to the agency’s description in NSW State Archives’s online catalogue.

Look up agency by name

https://www.opengov.nsw.gov.au/agencies/getByName.json

Returns a JSON object describing agencies matching with the given name. This information comprises descriptive metadata and a list of mathcing agencies.

List all publication types

https://www.opengov.nsw.gov.au/types
or, https://www.opengov.nsw.gov.au/types/all.json

Returns a JSON list of all publication types.

Extract metadata for a particular publication file

https://www.opengov.nsw.gov.au/publications/{publication file id}.json

Returns a JSON object describing a publication. This information comprises descriptive metadata and a list of publication files.

Extract text for a particular publication file

https://www.opengov.nsw.gov.au/publications/{publication file id}.txt

Returns the extracted text contents of a publication file.

Return the pdf for a particular publication file

https://www.opengov.nsw.gov.au/publications/{publication file id}.pdf

Returns the publication file's pdf.

Upload publication and its files remotely

https://www.opengov.nsw.gov.au/publications/requestPublication.json

- requestJson: mandatory

For example:

{
"userId":"agency@records.nsw.gov.au",
"password":"password123",
"title":"title",
"description":"description",
"agencies":["24135","24133","24136","24134"],
"publishers":["24135","24134","24136","24133"],
"keywords":["social"," something new"],
"type":"Annual Report",
"typeOther":"",
"datePublished":"20021203",
"files": ["http://www.agency_url/download/pdf"],
"language":"language",
"copyright":"copyright",
"coverage":"coverage"
}

% userId, password, title, agencies, type, datePublished are mandatory and datePublished must be of YYYYMMDD format.

Returns result messages.