Skip to content

Address

List all addresses.

GET /address

Returns:

Type Description
List[Dict[str, Any]]

List of address representations.

Source code in nukiwebapi/address.py
11
12
13
14
15
16
17
18
19
20
def list_addresses(self) -> List[Dict[str, Any]]:
    """
    List all addresses.

    GET /address

    Returns:
        List of address representations.
    """
    return self.client._request("GET", "/address").json()

Create a new address.

PUT /address

Parameters:

Name Type Description Default
name str

Name of the address (mandatory).

required
smartlock_ids List[int]

List of smartlock IDs (mandatory).

required

Returns:

Type Description
Dict[str, Any]

Created address representation.

Source code in nukiwebapi/address.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def create_address(self, name: str, smartlock_ids: List[int]) -> Dict[str, Any]:
    """
    Create a new address.

    PUT /address

    Args:
        name (str): Name of the address (mandatory).
        smartlock_ids (List[int]): List of smartlock IDs (mandatory).

    Returns:
        Created address representation.
    """
    if not name:
        raise ValueError("name is required")
    if not smartlock_ids or not all(isinstance(s, int) for s in smartlock_ids):
        raise ValueError("smartlock_ids must be a non-empty list of integers")

    payload = {"name": name, "smartlockIds": smartlock_ids}
    return self.client._request("PUT", "/address", json=payload).json()

Update an existing address.

POST /address/{addressId}

Parameters:

Name Type Description Default
address_id int

Address ID (mandatory).

required
name str

New name for the address.

None
smartlock_ids List[int]

Updated list of smartlock IDs.

None
settings dict

Address settings.

None

Returns:

Type Description
Dict[str, Any]

Updated address representation.

Source code in nukiwebapi/address.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def update_address(
    self,
    address_id: int,
    name: Optional[str] = None,
    smartlock_ids: Optional[List[int]] = None,
    settings: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
    """
    Update an existing address.

    POST /address/{addressId}

    Args:
        address_id (int): Address ID (mandatory).
        name (str, optional): New name for the address.
        smartlock_ids (List[int], optional): Updated list of smartlock IDs.
        settings (dict, optional): Address settings.

    Returns:
        Updated address representation.
    """
    if not isinstance(address_id, int):
        raise ValueError("address_id must be an integer")

    payload: Dict[str, Any] = {}
    if name is not None:
        payload["name"] = name
    if smartlock_ids is not None:
        if not all(isinstance(s, int) for s in smartlock_ids):
            raise ValueError("smartlock_ids must be a list of integers")
        payload["smartlockIds"] = smartlock_ids
    if settings is not None:
        if not isinstance(settings, dict):
            raise ValueError("settings must be a dict")
        payload["settings"] = settings

    return self.client._request("POST", f"/address/{address_id}", json=payload).json()

Delete an existing address.

DELETE /address/{addressId}

Parameters:

Name Type Description Default
address_id int

Address ID to delete.

required

Returns:

Type Description
Dict[str, Any]

API response.

Source code in nukiwebapi/address.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
def delete_address(self, address_id: int) -> Dict[str, Any]:
    """
    Delete an existing address.

    DELETE /address/{addressId}

    Args:
        address_id (int): Address ID to delete.

    Returns:
        API response.
    """
    if not isinstance(address_id, int):
        raise ValueError("address_id must be an integer")
    return self.client._request("DELETE", f"/address/{address_id}").json()

List all address units for a given address.

GET /address/{addressId}/unit

Parameters:

Name Type Description Default
address_id int

Address ID.

required

Returns:

Type Description
List[Dict[str, Any]]

List of address units.

Source code in nukiwebapi/address.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
def list_address_units(self, address_id: int) -> List[Dict[str, Any]]:
    """
    List all address units for a given address.

    GET /address/{addressId}/unit

    Args:
        address_id (int): Address ID.

    Returns:
        List of address units.
    """
    if not isinstance(address_id, int):
        raise ValueError("address_id must be an integer")
    return self.client._request("GET", f"/address/{address_id}/unit").json()

Create a new unit for a given address.

PUT /address/{addressId}/unit

Parameters:

Name Type Description Default
address_id int

Address ID.

required
name str

Name of the new unit.

required

Returns:

Type Description
Dict[str, Any]

Created address unit representation.

Source code in nukiwebapi/address.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
def create_address_unit(self, address_id: int, name: str) -> Dict[str, Any]:
    """
    Create a new unit for a given address.

    PUT /address/{addressId}/unit

    Args:
        address_id (int): Address ID.
        name (str): Name of the new unit.

    Returns:
        Created address unit representation.
    """
    if not isinstance(address_id, int):
        raise ValueError("address_id must be an integer")
    if not name:
        raise ValueError("name is required for creating an address unit")

    payload = {"name": name}
    return self.client._request("PUT", f"/address/{address_id}/unit", json=payload).json()

Delete multiple units of a given address asynchronously.

DELETE /address/{addressId}/unit

Parameters:

Name Type Description Default
address_id int

Address ID.

required
unit_ids List[str]

List of unit IDs to delete.

required

Returns:

Type Description
Dict[str, Any]

API response with request ID and any errors.

Source code in nukiwebapi/address.py
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
def delete_address_units(self, address_id: int, unit_ids: List[str]) -> Dict[str, Any]:
    """
    Delete multiple units of a given address asynchronously.

    DELETE /address/{addressId}/unit

    Args:
        address_id (int): Address ID.
        unit_ids (List[str]): List of unit IDs to delete.

    Returns:
        API response with request ID and any errors.
    """
    if not isinstance(address_id, int):
        raise ValueError("address_id must be an integer")
    if not isinstance(unit_ids, list) or not all(isinstance(u, str) for u in unit_ids):
        raise ValueError("unit_ids must be a list of strings")

    return self.client._request("DELETE", f"/address/{address_id}/unit", json=unit_ids).json()

Delete a specific unit of a given address.

DELETE /address/{addressId}/unit/{id}

Parameters:

Name Type Description Default
address_id int

Address ID.

required
unit_id str

Unit ID to delete.

required

Returns:

Type Description
Dict[str, Any]

API response with request ID and any errors.

Source code in nukiwebapi/address.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
def delete_address_unit(self, address_id: int, unit_id: str) -> Dict[str, Any]:
    """
    Delete a specific unit of a given address.

    DELETE /address/{addressId}/unit/{id}

    Args:
        address_id (int): Address ID.
        unit_id (str): Unit ID to delete.

    Returns:
        API response with request ID and any errors.
    """
    if not isinstance(address_id, int):
        raise ValueError("address_id must be an integer")
    if not isinstance(unit_id, str):
        raise ValueError("unit_id must be a string")

    return self.client._request("DELETE", f"/address/{address_id}/unit/{unit_id}").json()