Skip to content

Hashtags API

The HashtagsAPI client exposes the community hashtag listing endpoint added in v0.5.0.

Resource grouping

The endpoint is grouped under client.hashtags (D-v0.5-1), separate from community or post resource clients.

Usage

from pynteracta.client import InteractaClient

with InteractaClient(base_url="https://tenant.example.com", credentials=...) as client:
    # List hashtags for a community
    page = client.hashtags.list_for_community(79)
    for ht in page.items_typed:
        print(ht.id, ht.name, ht.external_id)

    # Iterate all pages lazily
    for ht in client.hashtags.iterate_for_community(79, name="eng"):
        print(ht.id, ht.name)

    # Include deleted hashtags
    page = client.hashtags.list_for_community(79, include_deleted=True)

Sort fields

Valid order_by values: 'name', 'externalId'. order_desc controls direction (default: descending).

API Reference

pynteracta.api.hashtags.HashtagsAPI

Bases: ResourceClient

Client for community hashtag listing endpoint.

list_for_community(community_id, *, page_token=None, page_size=None, name=None, include_deleted=None, order_by=None, order_desc=None)

POST /admin/data/communities/{communityId}/hashtags.

Parameters:

Name Type Description Default
community_id int

The community whose hashtags to list.

required
page_token str | None

Pagination cursor from a previous response.

None
page_size int | None

Maximum items per page.

None
name str | None

Filter by hashtag name (substring match).

None
include_deleted bool | None

Include deleted hashtags (default: False).

None
order_by str | None

Sort field. Valid values: 'name', 'externalId'.

None
order_desc bool | None

True for descending, False for ascending (default: True).

None

list_for_community_raw(community_id, req)

POST hashtag list with a pre-built request DTO (escape hatch).

iterate_for_community(community_id, *, page_size=None, name=None, include_deleted=None, order_by=None, order_desc=None)

Lazy iterator over all pages of :meth:list_for_community.

Facade Reference

pynteracta.models.facade.hashtags.Hashtag

Thin facade over :class:~generated.AdminHashtagDTO.

AdminListHashtagsResponseDTO.items are typed as AdminHashtagDTOModel (RootModel[Any] stubs); the typed sibling is the plain AdminHashtagDTO.

Attributes:

Name Type Description
raw

The underlying typed DTO; access additional fields via this escape hatch.

Source code in src/pynteracta/models/facade/hashtags.py
class Hashtag:
    """Thin facade over :class:`~generated.AdminHashtagDTO`.

    ``AdminListHashtagsResponseDTO.items`` are typed as ``AdminHashtagDTOModel``
    (``RootModel[Any]`` stubs); the typed sibling is the plain ``AdminHashtagDTO``.

    Attributes:
        raw: The underlying typed DTO; access additional fields via this escape hatch.
    """

    def __init__(self, raw: generated.AdminHashtagDTO) -> None:
        self.raw = raw

    @property
    def id(self) -> int | None:
        return self.raw.id

    @property
    def name(self) -> str | None:
        return self.raw.name

    @property
    def community_id(self) -> int | None:
        return self.raw.communityId

    @property
    def external_id(self) -> str | None:
        return self.raw.externalId

    @property
    def deleted(self) -> bool | None:
        return self.raw.deleted

    @classmethod
    def from_dict(cls, data: dict) -> Hashtag:  # type: ignore[type-arg]
        """Parse from a raw dict item."""
        raw = generated.AdminHashtagDTO.model_validate(data)
        return cls(raw)

from_dict(data) classmethod

Parse from a raw dict item.

Source code in src/pynteracta/models/facade/hashtags.py
@classmethod
def from_dict(cls, data: dict) -> Hashtag:  # type: ignore[type-arg]
    """Parse from a raw dict item."""
    raw = generated.AdminHashtagDTO.model_validate(data)
    return cls(raw)

pynteracta.models.facade.hashtags.HashtagList

Narrow facade over :class:~generated.AdminListHashtagsResponseDTO.

items are AdminHashtagDTOModel (RootModel[Any] stubs); call :meth:items_typed to get :class:Hashtag instances.

Attributes:

Name Type Description
raw

The underlying generated DTO; access additional fields via this escape hatch.

Source code in src/pynteracta/models/facade/hashtags.py
class HashtagList:
    """Narrow facade over :class:`~generated.AdminListHashtagsResponseDTO`.

    ``items`` are ``AdminHashtagDTOModel`` (``RootModel[Any]`` stubs); call
    :meth:`items_typed` to get :class:`Hashtag` instances.

    Attributes:
        raw: The underlying generated DTO; access additional fields via this escape hatch.
    """

    def __init__(self, raw: generated.AdminListHashtagsResponseDTO) -> None:
        self.raw = raw

    @property
    def next_page_token(self) -> str | None:
        return self.raw.nextPageToken

    @property
    def total_items_count(self) -> int | None:
        return self.raw.totalItemsCount

    @property
    def items_typed(self) -> list[Hashtag]:
        """Re-validate each opaque ``AdminHashtagDTOModel`` stub into :class:`Hashtag`."""
        if not self.raw.items:
            return []
        result = []
        for item in self.raw.items:
            root = _resolve_root(item)
            if isinstance(root, dict):
                result.append(Hashtag(generated.AdminHashtagDTO.model_validate(root)))
        return result

    @classmethod
    def from_dict(cls, data: dict) -> HashtagList:  # type: ignore[type-arg]
        """Parse from a raw API response dict."""
        raw = generated.AdminListHashtagsResponseDTO.model_validate(data)
        return cls(raw)

items_typed property

Re-validate each opaque AdminHashtagDTOModel stub into :class:Hashtag.

from_dict(data) classmethod

Parse from a raw API response dict.

Source code in src/pynteracta/models/facade/hashtags.py
@classmethod
def from_dict(cls, data: dict) -> HashtagList:  # type: ignore[type-arg]
    """Parse from a raw API response dict."""
    raw = generated.AdminListHashtagsResponseDTO.model_validate(data)
    return cls(raw)