From da7048cbd6dca144f924b97aafeef2e2cd7145c0 Mon Sep 17 00:00:00 2001 From: Vera Sativa Date: Wed, 15 Oct 2025 19:30:13 -0300 Subject: [PATCH] feat: add list_objects method to Client class --- anytype_client/client.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/anytype_client/client.py b/anytype_client/client.py index 13eeb6c..4df1f42 100644 --- a/anytype_client/client.py +++ b/anytype_client/client.py @@ -369,6 +369,27 @@ def delete_space(self, space_id: str) -> bool: return True # Object methods + def list_objects(self, space_id: str,) -> Object: + """Get an object by ID. + + Args: + space_id: ID of the space containing the object. + + Returns: + Object with the specified ID. + """ + response = self.request("GET", f"spaces/{space_id}/objects") + # Handle the actual API response format with 'data' key + if isinstance(response, dict) and "data" in response and isinstance(response["data"], list): + objects = [] + for objects_data in response["data"]: + try: + objects.append(Object.model_validate(objects_data)) + except Exception: + logger.error(f"Failed to parse objects data: {space_data}") + raise + return objects + def get_object(self, space_id: str, object_id: str) -> Object: """Get an object by ID.