RESTful API is an interface that two computer systems use to exchange information securely over the internet.
Currently we have one public API in the GW website, for notices on our parks pages.
Endpoint
/api/v1/parks/{park-url}
This API endpoint is used to fetch park data.
Request Methods
GET: Fetches data for a specific park or all parks.
Parameters
park-url (optional): The URL slug of the park (same as park page url) you want to fetch data for. If this parameter is not provided, the API will return data for all parks.
Responses
200 OK: The request was successful. The response body will contain the park data.
404 Not Found: The requested park was not found. The response body will contain an error message.
405 Method Not Allowed: The request method is not supported by the endpoint.
500 Internal Server Error: something wrong with the website server
Example usage
To fetch data for a specific park: for e.g. Akatarawa Forest
GET /api/v1/parks/akatarawa-forest
To fetch data for all parks:
GET /api/v1/parks
Response format
The response will be in JSON format. For a specific park, the response will contain the park's data. For all parks, the response will be an array of park data.
Please note that the actual URL for the endpoint will depend on the base URL of the API.
So the full url would be something like - gw.govt.nz/api/v1/parks/akatarawa-forest
Data
The returned array contains the following keys:
- name: The title of the park.
- address: The address of the park.
- url: The absolute URL of the park.
- activities: An array of activity types available at the park. If no activities are available, this will be an empty array.
- notices: An array of notices for the park. Each notice is an associative array with the keys title, message, and severe.