diff --git a/examples/README.md b/examples/README.md
index fa4716e1..47697c85 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -41,6 +41,12 @@
group_information.py
diff --git a/examples/group_search.py b/examples/group_search.py
new file mode 100644
index 00000000..786b749f
--- /dev/null
+++ b/examples/group_search.py
@@ -0,0 +1,16 @@
+"""
+Searches for groups which have a keyword in their name.
+"""
+
+import asyncio
+from roblox import Client
+client = Client()
+
+async def main():
+ users = client.group_search("Roblox", max_items=10)
+
+ async for user in users:
+ print("ID:", group.id)
+ print("\tName:", group.name)
+
+asyncio.get_event_loop().run_until_complete(main())
diff --git a/roblox/client.py b/roblox/client.py
index fbea3a43..2ae3720c 100644
--- a/roblox/client.py
+++ b/roblox/client.py
@@ -21,6 +21,7 @@
from .delivery import DeliveryProvider
from .groups import Group
from .partials.partialuser import PartialUser, RequestedUsernamePartialUser, PreviousUsernamesPartialUser
+from .partials.partialgroup import UniversePartialGroup, RequestedGroupnamePartialGroup
from .places import Place
from .plugins import Plugin
from .presence import PresenceProvider
@@ -291,6 +292,28 @@ def get_base_group(self, group_id: int) -> BaseGroup:
A BaseGroup.
"""
return BaseGroup(client=self, group_id=group_id)
+
+ def group_search(self, keyword: str, page_size: int = 10,
+ max_items: int = None, prioritize_match: bool = True) -> PageIterator:
+ """
+ Search for users with a keyword.
+
+ Arguments:
+ keyword: A keyword to search for.
+ page_size: How many members should be returned for each page.
+ max_items: The maximum items to return when looping through this object.
+
+ Returns:
+ A PageIterator containing RequestedUsernamePartialUser.
+ """
+ return PageIterator(
+ shared=self._shared,
+ url=self._shared.url_generator.get_url("groups", f"v1/groups/search"),
+ page_size=page_size,
+ max_items=max_items,
+ extra_parameters={"keyword": keyword, "prioritizeExactMatch": prioritize_match}
+ handler=lambda shared, data: RequestedGroupnamePartialGroup(shared, data),
+ )
# Universes
async def get_universes(self, universe_ids: List[int]) -> List[Universe]:
diff --git a/roblox/partials/partialgroup.py b/roblox/partials/partialgroup.py
index fa4574a7..2c9a6117 100644
--- a/roblox/partials/partialgroup.py
+++ b/roblox/partials/partialgroup.py
@@ -72,3 +72,21 @@ def __init__(self, client: Client, data: dict):
def __repr__(self):
return f"<{self.__class__.__name__} id={self.id} name={self.name!r}>"
+
+class RequestedGroupnamePartialGroup(UniversePartialGroup):
+ """
+ Represents a partial group in the context of a search query.
+
+ Attributes:
+ requested_groupname: Group name they requested
+ """
+
+ def __init__(self, shared: ClientSharedObject, data: dict):
+ """
+ Arguments:
+ shared: The ClientSharedObject.
+ data: The data form the endpoint.
+ """
+ super().__init__(shared=shared, data=data)
+
+ self.requested_groupname: str = data.get("requestedGroupname")
|