diff --git a/src/apify_client/_models.py b/src/apify_client/_models.py index 9c1d304da..18476a6dc 100644 --- a/src/apify_client/_models.py +++ b/src/apify_client/_models.py @@ -4123,6 +4123,45 @@ class SourceCodeFolder(BaseModel): """ +@docs_group('Models') +class Stats(BaseModel): + """Actor usage statistics and Apify Store metrics returned by the Store endpoint.""" + + model_config = ConfigDict( + extra='allow', + populate_by_name=True, + alias_generator=to_camel, + ) + total_users: Annotated[int, Field(examples=[6])] + """ + The total number of Actor users, including its owner. + """ + total_runs: Annotated[int | None, Field(examples=[16])] = None + """ + The total number of runs of the Actor. + """ + total_users7_days: Annotated[int | None, Field(examples=[2])] = None + """ + The number of active users of the Actor in the last 7 days. + """ + total_users30_days: Annotated[int | None, Field(examples=[6])] = None + """ + The number of active users of the Actor in the last 30 days. + """ + total_users90_days: Annotated[int | None, Field(examples=[6])] = None + """ + The number of active users of the Actor in the last 90 days. + """ + actor_review_rating: Annotated[float, Field(examples=[4.7])] + """ + The average rating of the Actor in Apify Store. + """ + actor_review_count: Annotated[int, Field(examples=[69])] + """ + The number of reviews the Actor has received in Apify Store. + """ + + @docs_group('Models') class StorageIds(BaseModel): """A map of aliased storage IDs associated with this run, grouped by storage type.""" @@ -4180,20 +4219,24 @@ class StoreActor(BaseModel): username: Annotated[str, Field(examples=['jane35'])] user_full_name: Annotated[str | None, Field(examples=['Jane H. Doe'])] = None description: Annotated[str | None, Field(examples=['My public actor!'])] = None - categories: Annotated[list[str] | None, Field(examples=[['MARKETING', 'LEAD_GENERATION']])] = None + categories: Annotated[list[str] | None, Field(examples=[['AI_AND_ML', 'GENERATE_LEADS']])] = None notice: ActorNotice | None = None picture_url: Annotated[str | None, Field(examples=['https://...'])] = None user_picture_url: Annotated[AnyUrl | None, Field(examples=['https://...'])] = None url: Annotated[AnyUrl | None, Field(examples=['https://...'])] = None - stats: ActorStats + stats: Annotated[Stats, Field(title='StoreActorStats')] + """ + Actor usage statistics and Apify Store metrics returned by the Store endpoint. + """ current_pricing_info: CurrentPricingInfo | None = None is_white_listed_for_agentic_payments: bool | None = None """ Whether the Actor is whitelisted for agentic payment processing. """ - actor_review_count: Annotated[int | None, Field(examples=[69])] = None - actor_review_rating: Annotated[float | None, Field(examples=[4.7])] = None - bookmark_count: Annotated[int | None, Field(examples=[1269])] = None + is_verified: Annotated[bool | None, Field(examples=[False])] = None + """ + Whether the Actor's developer has a verified identity. + """ badge: Annotated[str | None, Field(examples=[None])] = None readme_summary: str | None = None """ diff --git a/src/apify_client/_resource_clients/store_collection.py b/src/apify_client/_resource_clients/store_collection.py index 98f328520..b5b2dcdc0 100644 --- a/src/apify_client/_resource_clients/store_collection.py +++ b/src/apify_client/_resource_clients/store_collection.py @@ -55,7 +55,8 @@ def list( offset: What Actor to include as first when retrieving the list. search: String to search by. The search runs on the following fields: title, name, description, username, readme. - sort_by: Specifies the field by which to sort the results. + sort_by: Deprecated. The API ignores this argument. Results are ordered by relevance when `search` is used, + and by Store position otherwise. category: Filter by this category. username: Filter by this username. pricing_model: Filter by this pricing model. @@ -106,7 +107,8 @@ def iterate( offset: What Actor to include as first when retrieving the list. search: String to search by. The search runs on the following fields: title, name, description, username, readme. - sort_by: Specifies the field by which to sort the results. + sort_by: Deprecated. The API ignores this argument. Results are ordered by relevance when `search` is used, + and by Store position otherwise. category: Filter by this category. username: Filter by this username. pricing_model: Filter by this pricing model. @@ -177,7 +179,8 @@ async def list( offset: What Actor to include as first when retrieving the list. search: String to search by. The search runs on the following fields: title, name, description, username, readme. - sort_by: Specifies the field by which to sort the results. + sort_by: Deprecated. The API ignores this argument. Results are ordered by relevance when `search` is used, + and by Store position otherwise. category: Filter by this category. username: Filter by this username. pricing_model: Filter by this pricing model. @@ -228,7 +231,8 @@ def iterate( offset: What Actor to include as first when retrieving the list. search: String to search by. The search runs on the following fields: title, name, description, username, readme. - sort_by: Specifies the field by which to sort the results. + sort_by: Deprecated. The API ignores this argument. Results are ordered by relevance when `search` is used, + and by Store position otherwise. category: Filter by this category. username: Filter by this username. pricing_model: Filter by this pricing model. diff --git a/tests/integration/test_store.py b/tests/integration/test_store.py index c3c7fe1bf..696e5bab2 100644 --- a/tests/integration/test_store.py +++ b/tests/integration/test_store.py @@ -68,17 +68,14 @@ async def test_store_list_filter_by_username(client: ApifyClient | ApifyClientAs assert actor.username == 'apify' -async def test_store_list_sort_by_popularity(client: ApifyClient | ApifyClientAsync) -> None: - """Test listing store actors sorted by popularity (a known API-supported sort field).""" +async def test_store_list_accepts_sort_by(client: ApifyClient | ApifyClientAsync) -> None: + """Test that the store listing accepts the deprecated `sort_by`. + + The API accepts `sortBy` for compatibility but ignores it, so the order is not asserted. + """ page = await maybe_await(client.store().list(limit=10, sort_by='popularity')) assert isinstance(page, ListOfStoreActors) assert len(page.items) > 0 - # `popularity` is a composite ranking, not a strict sort on any single field, so we only - # check the directional invariant: the top-ranked item has at least as many total users as - # the bottom-ranked one on the page. - total_users = [a.stats.total_users for a in page.items if a.stats.total_users is not None] - assert total_users, 'expected at least one item with populated stats.total_users' - assert total_users[0] >= total_users[-1] async def test_store_iterate(client: ApifyClient | ApifyClientAsync, *, is_async: bool) -> None: @@ -132,7 +129,7 @@ async def test_store_list_parses_full_first_page(client: ApifyClient | ApifyClie assert isinstance(page, ListOfStoreActors) # All items have already been validated by Pydantic via `model_validate`. Touch a few # fields to make the assertion concrete and to ensure the page wasn't empty. - assert page.items, f'{type(page).__name__} returned an empty items list — unexpected for the public store' + assert page.items, f'{type(page).__name__} returned an empty items list - unexpected for the public store' for item in page.items: assert item.id assert item.name