lobstr.client.Lobstr

main client class for interacting with the Lobstr API.

Attributes:

Name Type Description
client AsyncClient

The HTTP client used for making requests.

user UserService

Service for user-related operations.

comment CommentService

Service for comment-related operations.

feed FeedService

Service for feed-related operations.

story StoryService

Service for story-related operations.

tag TagService

Service for tag-related operations.

Source code in lobstr/client.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class Lobstr:
    """
    main client class for interacting with the Lobstr API.

    Attributes:
        client (httpx.AsyncClient): The HTTP client used for making requests.
        user (UserService): Service for user-related operations.
        comment (CommentService): Service for comment-related operations.
        feed (FeedService): Service for feed-related operations.
        story (StoryService): Service for story-related operations.
        tag (TagService): Service for tag-related operations.
    """

    def __init__(
        self,
        base_url: str = CONSTANTS.BASE_URL,
        timeout: int = CONSTANTS.DEFAULT_TIMEOUT,
    ) -> None:
        self.client: httpx.AsyncClient = httpx.AsyncClient(
            base_url=base_url,
            timeout=timeout,
            event_hooks={
                # "response": [raise_for_status],
            },
        )

        self.user = UserService(self.client)
        self.comment = CommentService(self.client)
        self.feed = FeedService(self.client)
        self.story = StoryService(self.client)
        self.tag = TagService(self.client)

    async def __aenter__(self):
        return self

    async def __aexit__(
        self,
        exc_type,
        exc,
        tb,
    ):
        await self.client.aclose()