aklapi

package module
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2025 License: BSD-2-Clause Imports: 12 Imported by: 0

README

Auckland Council API (unofficial)

Full list of available endpoints, for detailed description see below.

Name Endpoint Parameters Comments
Address /api/v1/addr addr: partial address Address Query
Rubbish and Recycling short /api/v1/rr addr: partial address Rubbish and Recycling, short format
Rubbish and Recycling /api/v1/rrext addr: partial address Rubbish and Recycling
Healthcheck /healthcheck Returns OK if alive
  • /api/v1/addr, parameter: addr -
Rubbish and Recycling

Two endpoints so far, both accepting addr parameter.

  • /api/v1/rr - rubbish and recycling, returns the JSON of the following format:

    {
        "rubbish": "2020-02-25",
        "recycle": "2020-02-25",
        "address": "Britomart, CBD"
    }
    
  • /api/v1/rrext - extended rubbish and recycling. Returns the JSON in the following format:

    {
        "Collections": [
            {
                "Day": "Monday 24 January",
                "Date": "2020-01-24T00:00:00+13:00",
                "Rubbish": true,
                "Recycle": true
            },
            {
                "Day": "Monday 31 January",
                "Date": "2020-01-31T00:00:00+13:00",
                "Rubbish": true,
                "Recycle": false
            }
        ],
        "Address": {
            "ID": "12342478585",
            "Address": "500 Queen Street, Auckland Central"
        }
    }
    

Example:

$ curl --location --request GET 'https://<server>/api/v1/rr?addr=500%20Queen%20Street'
{"rubbish":"2020-02-24","recycle":"2020-02-24","address":"500 Queen Street, Auckland Central"}
Integrating with Home Assistant

Assuming your aklapi API server running on localhost:5010, add the following to your configuration.yaml:

rest:
  - resource: http://localhost:5010/api/v1/rr?addr=xx
    method: GET
    scan_interval: 300
    sensor:
      - name: Recycle
        value_template: "{{ value_json.recycle }}"
        device_class: date
        unique_id: recycle_date
      - name: Food Scraps
        value_template: "{{ value_json.foodscraps }}"
        device_class: date
        unique_id: foodscraps_date
      - name: Rubbish
        value_template: "{{ value_json.rubbish }}"
        device_class: date
        unique_id: rubbish_date

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoCache = false

NoCache is a flag to disable caching of the results.

Functions

This section is empty.

Types

type AddrRequest

type AddrRequest struct {
	PageSize   int
	SearchText string
}

AddrRequest is the address request.

type AddrResponse

type AddrResponse struct {
	Items []Address `json:"items"`
}

AddrResponse is the address response.

func AddressLookup

func AddressLookup(ctx context.Context, addr string) (*AddrResponse, error)

AddressLookup is a convenience function to get addresses.

func MatchingPropertyAddresses

func MatchingPropertyAddresses(ctx context.Context, addrReq *AddrRequest) (*AddrResponse, error)

MatchingPropertyAddresses wrapper around the AKL Council API.

type Address

type Address struct {
	ID      string `json:"ID"`
	Address string `json:"Address"`
}

Address is the address and its unique identifier (rate account key).

func (Address) String

func (s Address) String() string

type CollectionDayDetailResult

type CollectionDayDetailResult struct {
	Collections []RubbishCollection
	Address     *Address
}

CollectionDayDetailResult contains the information about Rubbish and Recycling collection.

func CollectionDayDetail

func CollectionDayDetail(ctx context.Context, addr string) (*CollectionDayDetailResult, error)

CollectionDayDetail returns a collection day details for the specified address as reported by the Auckland Council Website.

func (*CollectionDayDetailResult) NextFoodScraps added in v1.1.0

func (res *CollectionDayDetailResult) NextFoodScraps() time.Time

NextFoodScraps returns the next food scraps collection date.

func (*CollectionDayDetailResult) NextRecycle

func (res *CollectionDayDetailResult) NextRecycle() time.Time

NextRecycle returns the next recycle collection date.

func (*CollectionDayDetailResult) NextRubbish

func (res *CollectionDayDetailResult) NextRubbish() time.Time

NextRubbish returns the next rubbish collection date.

type RubbishCollection

type RubbishCollection struct {
	Day        string
	Date       time.Time
	Rubbish    bool
	Recycle    bool
	FoodScraps bool
}

RubbishCollection contains the date and type of collection.

func (*RubbishCollection) String added in v1.2.3

func (r *RubbishCollection) String() string

func (*RubbishCollection) Type added in v1.2.3

func (r *RubbishCollection) Type() string

Directories

Path Synopsis
cmd
aklapi command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL