### Using site.get() Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/site.md Example of calling get() and printing the site name. ```python site = lemmy.site.get() if site: print(site["site_view"]["site"]["name"]) ``` -------------------------------- ### Example call to create Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/community.md Example usage of the create method. Requires authentication. ```python lemmy.community.create(name="mycomm", title="My Community", description="A test community") ``` -------------------------------- ### Get modlog with pagination and filters Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/modlog.md Two examples of using the get method with pagination and different filters. ```python mods = lemmy.modlog.get(mod_person_id=42, limit=20, page=1) mods = lemmy.modlog.get(other_person_id=7, type_=ModlogActionType.AdminPurgePerson) ``` -------------------------------- ### get community by name example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/community.md Example usage of the get method to fetch a community by name and print its id. Checks for a non-None result before accessing the community_view. ```python comm = lemmy.community.get(name="botart") if comm: print(comm["community_view"]["community"]["id"]) ``` -------------------------------- ### get usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/comment.md Example of calling `lemmy.comment.get` with a comment ID and printing the comment content. ```python comment_view = lemmy.comment.get(5678) print(comment_view.get("comment_view", {}).get("comment", {}).get("content")) ``` -------------------------------- ### create usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/post.md Example call to create a new post. Uses LanguageType.EN for language_id. Requires authentication. ```python new = lemmy.post.create( community_id=community_id, name="Hello Lemmy World", body="A post from pythorhead", language_id=LanguageType.EN, ) ``` -------------------------------- ### create usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/comment.md Example of creating a top-level comment and a reply using `lemmy.comment.create`. ```python lemmy.comment.create(post_id=123, content="Hello Lemmy World") reply = lemmy.comment.create(post_id=123, content="A reply", parent_id=parent_comment_id) ``` -------------------------------- ### LemmyUser usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/classes.md Example usage: fetches a user, prints latest posts, and updates settings. ```python user = lemmy.get_user(username="db0") print(user.get_latest_posts()) # refreshes then returns user.posts user.set_settings(theme="dark", show_nsfw=True) ``` -------------------------------- ### Search posts example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/lemmy.md Example usage of the `search` method to find posts with type `SearchType.Posts` and sort `SortType.TopAll`, then print the post names from the results. ```python results = lemmy.search(q="lemmy", type_=SearchType.Posts, sort=SortType.TopAll) for post_view in (results or {}).get("posts", []): print(post_view["post"]["name"]) ``` -------------------------------- ### List comments example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/comment.md Example call to list comments for a post, sorted by top. ```python comments = lemmy.comment.list(post_id=post_id, sort=CommentSortType.Top) ``` -------------------------------- ### like post usage examples Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/post.md Example calls to like a post with upvote and downvote scores. ```python lemmy.post.like(post_id=123, score=1) # upvote lemmy.post.like(post_id=123, score=-1) # downvote ``` -------------------------------- ### Lemmy instantiation example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/lemmy.md Creates a Lemmy client for the instance at https://lemmy.dbzer0.com with exception raising enabled. ```python from pythorhead import Lemmy lemmy = Lemmy("https://lemmy.dbzer0.com", raise_exceptions=True, request_timeout=3) ``` -------------------------------- ### List private messages example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/private_message.md Example of listing private messages and printing content of each. ```python msgs = lemmy.private_message.list(unread_only=True, page=1) for m in (msgs or {}).get("private_messages", []): print(m["private_message"]["content"]) ``` -------------------------------- ### delete usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/post.md Example call to delete a post. Pass deleted=True to delete, False to restore. Requires authentication as the author. ```python lemmy.post.delete(post_id=123, deleted=True) ``` -------------------------------- ### log_in usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/lemmy.md Logs in with a username and password. Prints a success or failure message based on the returned boolean. ```python lemmy = Lemmy("https://lemmy.dbzer0.com") if lemmy.log_in("my_user", "my_password"): print(f"Logged in as {lemmy.username}") else: print("Login failed") ``` -------------------------------- ### List registration applications example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/admin.md Calls list_applications with limit=10 and iterates over the response's registration_applications to print answers. Returns None on failure. ```python apps = lemmy.admin.list_applications(limit=10) if apps: for app in apps["registration_applications"]: print(app["registration_application"]["answer"]) ``` -------------------------------- ### Mark messages as read example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/private_message.md Example of marking all unread messages as read by iterating over the list. ```python for m in (lemmy.private_message.list(unread_only=True, page=1) or {}).get("private_messages", []): lemmy.private_message.mark_as_read(m["private_message"]["id"], True) ``` -------------------------------- ### Process registration applications example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/admin.md Fetches unread applications and rejects those containing 'spam' in the answer, otherwise accepts. Uses LemmyRegistrationApplication.accept() and reject(). ```python apps = lemmy.get_registration_applications(unread_only="true") for app in apps: if "spam" in app.answer.lower(): app.reject(deny_reason="Looks like spam") else: app.accept() ``` -------------------------------- ### Create private message example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/private_message.md Example of creating a private message. Retrieves recipient id via lemmy.user.get and passes content and recipient_id. ```python recipient = lemmy.user.get(username="someone") pm = lemmy.private_message.create( content="Hello from pythorhead", recipient_id=recipient["person_view"]["person"]["id"], ) ``` -------------------------------- ### get_version() returns installed package version Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/lemmy.md Module-level function that returns the installed pythorhead version string via importlib.metadata.version. Used internally to build the User-Agent header of every request. ```python def get_version(): return version('pythorhead') ``` -------------------------------- ### site_metadata usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/post.md Calls site_metadata with a GitHub URL to fetch its OpenGraph metadata. ```python meta = lemmy.post.site_metadata("https://github.com/db0/pythorhead") ``` -------------------------------- ### get Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/site.md Retrieves the full site view, including admins, counts, custom emojis, and taglines. Returns a dictionary or None on failure. ```APIDOC ## GET /site ### Description Retrieves the full site view, including admins, counts, custom emojis, and taglines. Returns a dictionary or None on failure. ### Method GET ### Endpoint /site ### Parameters None ### Request Example No request body required. ### Response #### Success Response (200) - **site_view** (object) - The site view containing site details. - **admins** (array) - List of admins. - **counts** (object) - Site statistics. - **custom_emojis** (array) - Custom emojis. - **taglines** (array) - Taglines. #### Response Example { "site_view": { "site": { "name": "Example" } } } ``` -------------------------------- ### GET /site Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Fetches site information, including custom emojis. ```APIDOC ## GET /site ### Description Fetches site information, including custom emojis. ### Method GET ### Endpoint `{base_url}/api/v3/site` ### Parameters No parameters. ### Response #### Success Response (200) - **site_view** (object) - The site view. - **custom_emojis** (array) - List of custom emojis. #### Response Example ```json { "site_view": {}, "custom_emojis": [] } ``` ``` -------------------------------- ### Using a Lemmy data class Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/classes.md Example usage of a data class returned by lemmy.get_user(). Shows how to serialize to JSON and access fields via asdict(). ```python user = lemmy.get_user(username="db0") print(user.asjson()) # pretty JSON, datetimes serialized print(user.asdict()["name"]) ``` -------------------------------- ### User.get method signature Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/user.md Defines the get method with optional parameters for fetching user content. Note that return_user_object is documented but not implemented in the source. ```python def get( self, person_id: Optional[str] = None, username: Optional[str] = None, sort: Optional[SortType] = None, page: Optional[int] = None, limit: Optional[int] = None, community_id: Optional[int] = None, saved_only: Optional[bool] = None, return_user_object = False, ) -> dict | None: ``` -------------------------------- ### get Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/community.md Fetches a community by id or name. Returns the community view or None if not found. ```APIDOC ## get ### Description Fetches a community by id or name. Returns the community view or None if not found. ### Method GET ### Endpoint /community ### Parameters #### Path Parameters None #### Query Parameters - `id` (Optional[int]) - Optional - Fetch by id. - `name` (Optional[str]) - Optional - Fetch by name (e.g. `"botart"` or `"name@instance"`). ### Request Example ```python comm = lemmy.community.get(name="botart") if comm: print(comm["community_view"]["community"]["id"]) ``` ### Response #### Success Response (200) - Returns `Optional[dict]` — `GET /community` response containing `community_view`; `None` when not found/failed. #### Response Example ```json { "community_view": { "community": { "id": 1 } } } ``` ### Error Handling - Returns `None` when not found/failed. ``` -------------------------------- ### Site.get method signature Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/site.md The get method signature, which takes no parameters and returns an Optional[dict]. ```python def get( self, ) -> Optional[dict]: ``` -------------------------------- ### Import and instantiate Site Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/site.md Shows how to import the Site and Requestor classes and create a Site instance. ```python from pythorhead.site import Site from pythorhead.requestor import Requestor site = Site(Requestor()) ``` -------------------------------- ### Get modlog with JSON output Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/modlog.md Example of fetching a modlog filtered by community and action type, printing the result as indented JSON. ```python import json modlog = lemmy.modlog.get(community_id=comm_id, type_=ModlogActionType.ModBan) if modlog: print(json.dumps(modlog, indent=4)) ``` -------------------------------- ### get method signature Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/comment.md Signature for the `get` method, which retrieves a comment by its ID. Returns a dict from the `GET /comment` response, or `{}` on failure. ```python def get( # noqa: A003 self, comment_id: int, ) -> dict: ``` -------------------------------- ### get_replies usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/comment.md Example call to `get_replies` with `unread_only=True` and `page=1`. ```python replies = lemmy.comment.get_replies(unread_only=True, page=1) ``` -------------------------------- ### Import and instantiate Modlog Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/modlog.md Shows how to import and create a Modlog instance with a Requestor. ```python from pythorhead.modlog import Modlog from pythorhead.requestor import Requestor modlog = Modlog(Requestor()) ``` -------------------------------- ### Create a post with Pythörhead Source: https://github.com/db0/pythorhead/blob/main/README.md Initialize a Lemmy client with a custom request timeout of 2 seconds, log in, discover a community by name, and create a post in that community. Requires valid credentials and a Lemmy instance URL. ```python from pythorhead import Lemmy lemmy = Lemmy("https://lemmy.dbzer0.com",request_timeout=2) lemmy.log_in("username", "password") community_id = lemmy.discover_community("botart") lemmy.post.create(community_id, "Hello Lemmy World") ``` -------------------------------- ### Instantiate Image client Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/image.md Instantiate the Image client with a Requestor. Accessed as lemmy.image in the main Lemmy class. ```python from pythorhead.image import Image from pythorhead.requestor import Requestor image = Image(Requestor()) ``` -------------------------------- ### get Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/emoji.md Retrieves the custom emojis array from the GET /site response. Returns None if the request fails. ```APIDOC ## get ### Description Retrieves the custom emojis array from the GET /site response. Returns None if the request fails. ### Method GET ### Endpoint /site ### Parameters None ### Response #### Success Response (200) - **custom_emojis** (array) - Array of custom emoji objects. #### Response Example { "custom_emojis": [ { "id": 1, "shortcode": "example", "category": "team", "image_url": "https://example.org/logo.png", "alt_text": "team logo", "keywords": "team,logo" } ] } ``` -------------------------------- ### Initialize Lemmy with defaults Source: https://github.com/db0/pythorhead/blob/main/_autodocs/configuration.md Basic initialization of the Lemmy client with default options. The api_base_url is the only required argument; raise_exceptions defaults to False and request_timeout to 3 seconds. ```python from pythorhead import Lemmy lemmy = Lemmy("https://lemmy.dbzer0.com") ``` -------------------------------- ### get_registration_applications class method and usage Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/lemmy.md Requires an admin session. Calls lemmy.admin.list_applications(**kwargs) and converts each registration application into a LemmyRegistrationApplication dataclass, including creator and admin details. Returns an empty list when list_applications returns None. The example shows listing applications with a limit and printing status. ```python def get_applications(lemmy, **kwargs) -> list[LemmyRegistrationApplication]: return_json = lemmy.admin.list_applications(**kwargs) regapps = [] if return_json is None: return regapps for data in return_json["registration_applications"]: data_dict = data["registration_application"] data_dict["creator_local_user"] = LemmyLocalUser.from_dict(data["creator_local_user"], lemmy) data_dict["creator"] = LemmyUser.from_dict(data["creator"], lemmy) data_dict["admin"] = None if data.get("admin"): admin_dict = data["admin"] admin_dict["is_admin"] = True data_dict["admin"] = LemmyUser.from_dict(admin_dict, lemmy) regapps.append(LemmyRegistrationApplication.from_dict(data_dict, lemmy)) return regapps ``` ```python regapps = lemmy.get_registration_applications(limit=10) for regapp in regapps: print(f"Application from user '{regapp.creator.name}' status: {regapp.get_application_status()}") ``` -------------------------------- ### get Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/modlog.md Retrieves the Lemmy moderation log with optional filters. Returns the raw `GET /modlog` response as a dictionary, or `None` on failure. ```APIDOC ## `get` ### Description Retrieves the Lemmy moderation log with optional filters. Returns the raw `GET /modlog` response as a dictionary, or `None` on failure. ### Method GET ### Endpoint `/modlog` ### Parameters #### Query Parameters - `comment_id` (Optional[int]) - Optional - Filter by target comment. - `community_id` (Optional[int]) - Optional - Filter by community. - `limit` (Optional[int]) - Optional - Results per page. - `mod_person_id` (Optional[int]) - Optional - Filter by acting moderator. - `other_person_id` (Optional[int]) - Optional - Filter by affected user. - `page` (Optional[int]) - Optional - Page number. - `post_id` (Optional[int]) - Optional - Filter by target post. - `type_` (Optional[ModlogActionType]) - Optional - Action type filter (e.g. `ModlogActionType.ModRemovePost`); sent **as-is** (no `.value` conversion). ### Request Example ```python modlog = lemmy.modlog.get(community_id=comm_id, type_=ModlogActionType.ModBan) ``` ### Response #### Success Response (200) - Returns `Optional[dict]` — the raw `GET /modlog` response, passed through unchanged. Lemmy populates one array per modlog action type (keys such as `removed_posts`, `locked_posts`, `featured_posts`, `removed_comments`, `removed_communities`, `banned_from_community`, `mod_added_community`, `mod_transferred_community`, `mod_added`, `banned`, `hidden_communities`, `admin_purged_persons`, `admin_purged_communities`, `admin_purged_posts`, `admin_purged_comments`), with at most one populated depending on the `type_` filter. The library does not extract any key — consumers read the arrays themselves. `None` on failure. #### Response Example ```python import json modlog = lemmy.modlog.get(community_id=comm_id, type_=ModlogActionType.ModBan) if modlog: print(json.dumps(modlog, indent=4)) ``` ``` -------------------------------- ### Create a comment on the first post with Pythörhead Source: https://github.com/db0/pythorhead/blob/main/README.md Initialize a Lemmy client, log in, retrieve the ID of the first post from the post list, and comment on it. Requires valid credentials and an existing post. ```python from pythorhead import Lemmy lemmy = Lemmy("https://lemmy.dbzer0.com") lemmy.log_in("username", "password") # getting the first post id post_id = lemmy.post.list()[0]["post"]["id"] # leave a comment lemmy.comment.create(post_id, "Hello Lemmy World") ``` -------------------------------- ### Lemmy.__init__ Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/lemmy.md Initializes a Lemmy client with the given API base URL, exception handling, and request timeout. Creates a shared Requestor and validates the instance via nodeinfo. ```APIDOC ## Lemmy.__init__ ### Description Initializes a Lemmy client with the given API base URL, exception handling, and request timeout. Creates a shared Requestor and validates the instance via nodeinfo. ### Method Constructor ### Signature ```python def __init__(self, api_base_url: str, raise_exceptions = False, request_timeout=3) -> None: ``` ### Parameters - **api_base_url** (str) - Required - Base URL of the Lemmy instance, e.g. `"https://lemmy.dbzer0.com"`. Passed to `Requestor.set_domain()`, which also fetches the nodeinfo to validate the instance. - **raise_exceptions** (bool) - Optional - Default `False`. When `False`, failed API calls return `None` (or `[]`/`{}` depending on method) and only log errors. When `True`, network exceptions are re-raised and HTTP errors raise `Exception`. - **request_timeout** (int) - Optional - Default `3`. Timeout in seconds for all API requests. ### Example ```python from pythorhead import Lemmy lemmy = Lemmy("https://lemmy.dbzer0.com", raise_exceptions=True, request_timeout=2) ``` ``` -------------------------------- ### list_votes usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/post.md Example usage of list_votes to retrieve and print the names and scores of users who liked a post. The response contains a post_likes array. ```python votes = lemmy.post.list_votes(post_id=123) for like in votes["post_likes"]: print(like["creator"]["name"], like["score"]) ``` -------------------------------- ### ban_user example with expiration Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/community.md Example of banning a user for 7 days with a reason. Uses a datetime object for the expiration, which is converted to a Unix timestamp internally. ```python from datetime import datetime, timedelta lemmy.community.ban_user( person_id=42, community_id=community_id, expires=datetime.now() + timedelta(days=7), reason="Rule 1 violation", ) ``` -------------------------------- ### save_user_settings method signature and example call Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/user.md Method signature for saving user settings. Only non-None values are sent; default_sort_type, default_listing_type, and discussion_languages are sent as-is without .value conversion. Requires authentication as the target user and returns the PUT /user/save_user_settings response. ```python def save_user_settings( self, show_nsfw: Optional[bool] = None, blur_nsfw: Optional[bool] = None, auto_expand: Optional[bool] = None, show_scores: Optional[bool] = None, theme: Optional[str] = None, default_sort_type: Optional[SortType] = None, default_listing_type: Optional[ListingType] = None, interface_language: Optional[str] = None, avatar: Optional[str] = None, banner: Optional[str] = None, display_name: Optional[str] = None, email: Optional[str] = None, bio: Optional[str] = None, matrix_user_id: Optional[str] = None, show_avatars: Optional[bool] = None, send_notifications_to_email: Optional[bool] = None, bot_account: Optional[bool] = None, show_bot_accounts: Optional[bool] = None, show_read_posts: Optional[bool] = None, discussion_languages: Union[int, LanguageType, None] = None, open_links_in_new_tab: Optional[bool] = None, infinite_scroll_enabled: Optional[bool] = None, post_listing_mode: Optional[str] = None, enable_keyboard_navigation: Optional[bool] = None, enable_animated_images: Optional[bool] = None, collapse_bot_comments: Optional[bool] = None, ) -> Optional[dict]: ``` ```python lemmy.user.save_user_settings( display_name="Bot ❤️", bot_account=True, discussion_languages=LanguageType.EN, ) ``` -------------------------------- ### Instantiate Community client Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/community.md Creates a Community instance using a Requestor. Accessed as lemmy.community. ```python from pythorhead.community import Community from pythorhead.requestor import Requestor community = Community(Requestor()) ``` -------------------------------- ### Request enum with GET, PUT, POST Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/requestor.md Defines the HTTP verbs used by the library. DELETE is intentionally absent; Image.delete() uses a GET to the pictrs delete URL. ```python class Request(Enum): GET = "GET" PUT = "PUT" POST = "POST" ``` -------------------------------- ### Instantiate Mention client Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/mention.md Creates a Mention instance using a Requestor. Accessed as lemmy.mention. ```python from pythorhead.mention import Mention from pythorhead.requestor import Requestor mention = Mention(Requestor()) ``` -------------------------------- ### get community method signature Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/community.md Signature for fetching a community by id or name. Returns the GET /community response containing community_view, or None when not found or failed. Used internally by Lemmy.discover_community(). ```python def get(self, id: Optional[int] = None, name: Optional[str] = None) -> Optional[dict]: ``` -------------------------------- ### Instantiate Admin client Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/admin.md Creates an Admin instance using a Requestor. Required for accessing admin-only registration-application endpoints. ```python from pythorhead.admin import Admin from pythorhead.requestor import Requestor admin = Admin(Requestor()) ``` -------------------------------- ### feature method signature and usage example Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/post.md Defines the feature method to feature or unfeature a post. Requires moderator/admin authentication. Sends a POST request to /post/feature. The usage example shows how to feature a post with FeatureType.Local. ```python def feature(self, post_id: int, feature: bool, feature_type: FeatureType) -> Optional[dict]: ``` ```python from pythorhead.types import FeatureType lemmy.post.feature(post_id=123, feature=True, feature_type=FeatureType.Local) ``` -------------------------------- ### GET /user/mention Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Fetches mentions for the logged-in user. ```APIDOC ## GET /user/mention ### Description Fetches mentions for the logged-in user. ### Method GET ### Endpoint `{base_url}/api/v3/user/mention` ### Parameters #### Query Parameters - **unread_only** (string) - Optional - "true" or "false" to filter unread mentions. - **sort** (string) - Optional - Sort order. - **page** (integer) - Optional - Page number. - **limit** (integer) - Optional - Number of mentions to return. ### Response #### Success Response (200) - **mentions** (array) - List of mentions. #### Response Example ```json { "mentions": [] } ``` ``` -------------------------------- ### `Comment.`__init__` Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/comment.md Initializes a Comment API client instance with a Requestor. ```APIDOC ## `Comment` — Comment API Client Exposes Lemmy's comment endpoints. Accessed as `lemmy.comment`. Constructor: ```python def __init__(self, _requestor: Requestor): self._requestor = _requestor ``` ``` -------------------------------- ### GET /user/replies Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Fetches replies to the logged-in user. ```APIDOC ## GET /user/replies ### Description Fetches replies to the logged-in user. ### Method GET ### Endpoint `{base_url}/api/v3/user/replies` ### Parameters #### Query Parameters - **unread_only** (string) - Optional - "true" or "false" to filter unread replies. - **page** (integer) - Optional - Page number. - **limit** (integer) - Optional - Number of replies to return. - **sort** (string) - Optional - Sort order. ### Response #### Success Response (200) - **replies** (array) - List of replies. #### Response Example ```json { "replies": [] } ``` ``` -------------------------------- ### GET /comment Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Fetches a single comment by its ID. ```APIDOC ## GET /comment ### Description Fetches a single comment by its ID. ### Method GET ### Endpoint `{base_url}/api/v3/comment` ### Parameters #### Query Parameters - **id** (integer) - Required - The comment ID. ### Response #### Success Response (200) - **comment_view** (object) - The comment view. #### Response Example ```json { "comment_view": {} } ``` ``` -------------------------------- ### GET /post/like/list Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Lists likes for a specific post. ```APIDOC ## GET /post/like/list ### Description Lists likes for a specific post. ### Method GET ### Endpoint `{base_url}/api/v3/post/like/list` ### Parameters #### Query Parameters - **post_id** (integer) - Required - The post ID. - **page** (integer) - Optional - Page number. - **limit** (integer) - Optional - Number of likes to return. ### Response #### Success Response (200) - **post_likes** (array) - List of post likes. #### Response Example ```json { "post_likes": [] } ``` ``` -------------------------------- ### Fetch user by username and print name Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/user.md Calls user.get with a username and prints the person's name and actor_id from the response. The response contains person_view, comments, and posts. ```python user = lemmy.user.get(username="db0") if user: person = user["person_view"]["person"] print(person["name"], person["actor_id"]) ``` -------------------------------- ### GET /post/site_metadata Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Fetches metadata for a given URL. ```APIDOC ## GET /post/site_metadata ### Description Fetches metadata for a given URL. ### Method GET ### Endpoint `{base_url}/api/v3/post/site_metadata` ### Parameters #### Query Parameters - **url** (string) - Required - The URL to fetch metadata for. ### Response #### Success Response (200) - **metadata** (object) - Site metadata view. #### Response Example ```json { "metadata": {} } ``` ``` -------------------------------- ### GET /modlog Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Fetches the moderation log with optional filters. ```APIDOC ## GET /modlog ### Description Fetches the moderation log with optional filters. ### Method GET ### Endpoint `{base_url}/api/v3/modlog` ### Parameters #### Query Parameters - **comment_id** (integer) - Optional - Filter by comment ID. - **community_id** (integer) - Optional - Filter by community ID. - **limit** (integer) - Optional - Number of entries to return. - **mod_person_id** (integer) - Optional - Filter by moderator user ID. - **other_person_id** (integer) - Optional - Filter by other user ID. - **page** (integer) - Optional - Page number. - **post_id** (integer) - Optional - Filter by post ID. - **type_** (string) - Optional - Type of modlog entries. ### Response #### Success Response (200) - **modlog** (array) - List of modlog entries. #### Response Example ```json { "modlog": [] } ``` ``` -------------------------------- ### Instantiate Post standalone Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/post.md Creates a Post client directly with a Requestor instance. Use this when you need the Post API without going through the main Lemmy client. ```python from pythorhead.post import Post from pythorhead.requestor import Requestor post = Post(Requestor()) ``` -------------------------------- ### GET /private_message/list Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Lists private messages for the logged-in user. ```APIDOC ## GET /private_message/list ### Description Lists private messages for the logged-in user. ### Method GET ### Endpoint `{base_url}/api/v3/private_message/list` ### Parameters #### Query Parameters - **unread_only** (string) - Optional - "true" or "false" to filter unread messages. - **page** (integer) - Optional - Page number. - **limit** (integer) - Optional - Number of messages to return. ### Response #### Success Response (200) - **private_messages** (array) - List of private messages. #### Response Example ```json { "private_messages": [] } ``` ``` -------------------------------- ### GET /community/list Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Lists communities with optional filtering and pagination. ```APIDOC ## GET /community/list ### Description Lists communities with optional filtering and pagination. ### Method GET ### Endpoint `{base_url}/api/v3/community/list` ### Parameters #### Query Parameters - **limit** (integer) - Optional - Number of communities to return. - **page** (integer) - Optional - Page number. - **sort** (string) - Optional - Sort order. - **type_** (string) - Optional - Listing type. ### Response #### Success Response (200) - **communities** (array) - List of community views. #### Response Example ```json { "communities": [] } ``` ``` -------------------------------- ### Instantiate Comment client Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/comment.md Creates a Comment instance using a Requestor. Accessed as lemmy.comment. ```python from pythorhead.comment import Comment from pythorhead.requestor import Requestor comment = Comment(Requestor()) ``` -------------------------------- ### create Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/community.md Creates a new community on the Lemmy instance. Requires authentication. Returns the response from the POST /community endpoint. ```APIDOC ## create ### Description Creates a new community on the Lemmy instance. Requires authentication. Returns the response from the POST /community endpoint. ### Method POST ### Endpoint /community ### Parameters #### Request Body - **name** (str) - Required - Community name (slug). - **title** (str) - Required - Display title. - **description** (Optional[str]) - Optional - Markdown description. - **icon** (Optional[str]) - Optional - Icon URL. - **banner** (Optional[str]) - Optional - Banner URL (declared in the signature but **not** sent in the request body — see caveat below). - **nsfw** (Optional[bool]) - Optional - NSFW flag. - **posting_restricted_to_mods** (Optional[bool]) - Optional - **Broken in source**: the guard `if [posting_restricted_to_mods] is not None:` is always true, so the payload always contains a `"[posting_restricted_to_mods]"` key whose value is `[None]` even when the parameter is `None`. A `False`/`True` value is wrapped in a list. - **discussion_languages** (Optional[List[Union[int, LanguageType]]]) - Optional - Only `LanguageType` members are sent (as `.value`); plain ints in the list are dropped. ### Request Example ```python lemmy.community.create(name="mycomm", title="My Community", description="A test community") ``` ### Response #### Success Response (200) Returns `Optional[dict]` — the response from the POST /community endpoint. ``` -------------------------------- ### GET /resolve_object Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Resolves a federated object by its canonical URL or ID. ```APIDOC ## GET /resolve_object ### Description Resolves a federated object by its canonical URL or ID. ### Method GET ### Endpoint `{base_url}/api/v3/resolve_object` ### Parameters #### Query Parameters - **q** (string) - Required - The query string (URL or ID) to resolve. ### Response #### Success Response (200) - **post** (object) - Resolved post view, if applicable. - **comment** (object) - Resolved comment view, if applicable. - **community** (object) - Resolved community view, if applicable. - **user** (object) - Resolved person view, if applicable. #### Response Example ```json { "post": {}, "comment": {}, "community": {}, "user": {} } ``` ``` -------------------------------- ### log_in(username_or_email, password, totp=None) Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/requestor.md Stores login credentials and delegates to _log_in to authenticate. ```APIDOC ## log_in(username_or_email, password, totp=None) ### Description Stores login credentials and delegates to _log_in to authenticate. ### Method `log_in` ### Signature ```python def log_in(self, username_or_email: str, password: str, totp: Optional[str] = None) -> bool: ``` ### Parameters - **username_or_email** (str) - Required - The username or email to log in with. - **password** (str) - Required - The password. - **totp** (Optional[str]) - Optional - Two-factor authentication token. ### Returns `bool` - `True` if login was successful, `False` otherwise. ``` -------------------------------- ### GET /nodeinfo/2.0.json Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Retrieves NodeInfo 2.0 metadata for the Lemmy instance. ```APIDOC ## GET /nodeinfo/2.0.json ### Description Retrieves the NodeInfo 2.0 metadata for the Lemmy instance, including software name and version. ### Method GET ### Endpoint `{base_url}/nodeinfo/2.0.json` ### Parameters No parameters. ### Response #### Success Response (200) - **software** (object) - Contains `name` and `version` fields. #### Response Example ```json { "software": { "name": "lemmy", "version": "0.19.0" } } ``` ``` -------------------------------- ### GET /user Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Fetches a user's profile, including their posts and comments. ```APIDOC ## GET /user ### Description Fetches a user's profile, including their posts and comments. ### Method GET ### Endpoint `{base_url}/api/v3/user` ### Parameters #### Query Parameters - **person_id** (integer) - Optional - The user ID. - **username** (string) - Optional - The username. - **sort** (string) - Optional - Sort order. - **page** (integer) - Optional - Page number. - **limit** (integer) - Optional - Number of items to return. - **community_id** (integer) - Optional - Filter by community ID. - **saved_only** (boolean) - Optional - Only return saved items. ### Response #### Success Response (200) - **person_view** (object) - The person view. - **comments** (array) - List of comment views. - **posts** (array) - List of post views. #### Response Example ```json { "person_view": {}, "comments": [], "posts": [] } ``` ``` -------------------------------- ### get_registration_applications(**kwargs) -> list[LemmyRegistrationApplication] Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/lemmy.md Retrieves a list of registration applications. Requires an admin session. Returns an empty list if no applications are found. ```APIDOC ## get_registration_applications ### Description Retrieves a list of registration applications. Requires an admin session. Returns an empty list if no applications are found. ### Method GET ### Endpoint (Underlying call: `lemmy.admin.list_applications(**kwargs)`) ### Parameters #### Query Parameters - **kwargs** - Required - Keyword arguments to pass to the underlying admin.list_applications method (e.g., `limit`). ### Response #### Success Response (200) Returns `list[LemmyRegistrationApplication]` - a list of registration application objects. Each object contains fields: `registration_application`, `creator_local_user`, `creator`, and `admin` (optional). #### Response Example ```python regapps = lemmy.get_registration_applications(limit=10) for regapp in regapps: print(f"Application from user '{regapp.creator.name}' status: {regapp.get_application_status()}") ``` ``` -------------------------------- ### GET /comment/report/list Source: https://github.com/db0/pythorhead/blob/main/_autodocs/endpoints.md Lists comment reports, optionally filtered by community and unresolved status. ```APIDOC ## GET /comment/report/list ### Description Lists comment reports, optionally filtered by community and unresolved status. ### Method GET ### Endpoint `{base_url}/api/v3/comment/report/list` ### Parameters #### Query Parameters - **community_id** (integer) - Optional - Filter by community ID. - **limit** (integer) - Optional - Number of reports to return. - **page** (integer) - Optional - Page number. - **unresolved_only** (string) - Optional - Lower-case string "true" or "false" to filter unresolved reports. ### Response #### Success Response (200) - **comment_reports** (array) - List of comment reports. #### Response Example ```json { "comment_reports": [] } ``` ``` -------------------------------- ### log_in method signature Source: https://github.com/db0/pythorhead/blob/main/_autodocs/api-reference/requestor.md Stores login credentials and delegates to _log_in. ```python def log_in(self, username_or_email: str, password: str, totp: Optional[str] = None) -> bool: ```