|
| 1 | +Api Client Core |
| 2 | +=============== |
| 3 | + |
| 4 | +.. mermaid:: |
| 5 | + |
| 6 | + graph LR |
| 7 | + API_Client_Core["API Client Core"] |
| 8 | + Client_Initializer["Client Initializer"] |
| 9 | + Request_Executor["Request Executor"] |
| 10 | + Response_Objectifier["Response Objectifier"] |
| 11 | + Rate_Limit_Manager["Rate Limit Manager"] |
| 12 | + API_Operation_Methods["API Operation Methods"] |
| 13 | + Async_Checker["Async Checker"] |
| 14 | + Client_Initializer -- "initializes" --> API_Client_Core |
| 15 | + API_Client_Core -- "manages" --> Request_Executor |
| 16 | + API_Client_Core -- "manages" --> Response_Objectifier |
| 17 | + API_Client_Core -- "manages" --> Rate_Limit_Manager |
| 18 | + API_Client_Core -- "exposes" --> API_Operation_Methods |
| 19 | + API_Operation_Methods -- "invokes" --> Request_Executor |
| 20 | + Request_Executor -- "checks" --> Async_Checker |
| 21 | + Request_Executor -- "returns raw response to" --> Response_Objectifier |
| 22 | + Response_Objectifier -- "transforms for" --> API_Operation_Methods |
| 23 | + API_Operation_Methods -- "consults" --> Rate_Limit_Manager |
| 24 | + click API_Client_Core href "https://github.com/praw-dev/praw/blob/main/.codeboarding/API_Client_Core.html" "Details" |
| 25 | + |
| 26 | +| |codeboarding-badge| |demo-badge| |contact-badge| |
| 27 | +
|
| 28 | +.. |codeboarding-badge| image:: https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square |
| 29 | + :target: https://github.com/CodeBoarding/CodeBoarding |
| 30 | +.. |demo-badge| image:: https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square |
| 31 | + :target: https://www.codeboarding.org/demo |
| 32 | +.. |contact-badge| image:: https://img.shields.io/badge/Contact%20us%20-%20contact@codeboarding.org-lightgrey?style=flat-square |
| 33 | + :target: mailto:contact@codeboarding.org |
| 34 | + |
| 35 | +Details |
| 36 | +------- |
| 37 | + |
| 38 | +The PRAW Reddit API client is structured around the `API Client Core`, which serves as the primary interface for users. This core is set up by the `Client Initializer`, configuring essential components like the HTTP client and response parsing. User interactions, such as fetching data or creating posts, are handled by `API Operation Methods`. These methods delegate the actual HTTP communication to the `Request Executor`, which may consult the `Async Checker` for proper asynchronous execution. Upon receiving a raw response, the `Request Executor` passes it to the `Response Objectifier` for transformation into structured Python objects, which are then returned to the `API Operation Methods`. Throughout this process, the `Rate Limit Manager` is consulted to ensure adherence to Reddit's API usage policies, with the `API Client Core` overseeing and managing these interactions. |
| 39 | + |
| 40 | +API Client Core |
| 41 | +^^^^^^^^^^^^^^^ |
| 42 | + |
| 43 | +:ref:`Expand <API_Client_Core>` |
| 44 | + |
| 45 | +Serves as the main entry point for users to interact with the Reddit API. It orchestrates all underlying operations, manages the client's state, and exposes a high-level, object-oriented interface. |
| 46 | + |
| 47 | +**Related Classes/Methods**: |
| 48 | + |
| 49 | +* `praw.reddit.Reddit:57-901 <https://github.com/praw-dev/praw/blob/main/praw/reddit.py#L57-L901>`_ |
| 50 | + |
| 51 | +Client Initializer |
| 52 | +^^^^^^^^^^^^^^^^^^ |
| 53 | + |
| 54 | +Sets up the API Client Core instance, including configuring the underlying HTTP client (prawcore) and the response objectification mechanism. It integrates `prawcore` for HTTP requests and the `Objector` for response parsing. |
| 55 | + |
| 56 | +**Related Classes/Methods**: |
| 57 | + |
| 58 | +* `praw.reddit.Reddit.__init__ <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 59 | +* `praw.reddit._prepare_prawcore:527-546 <https://github.com/praw-dev/praw/blob/main/praw/reddit.py#L527-L546>`_ |
| 60 | +* `praw.reddit._prepare_objector:479-525 <https://github.com/praw-dev/praw/blob/main/praw/reddit.py#L479-L525>`_ |
| 61 | + |
| 62 | +Request Executor |
| 63 | +^^^^^^^^^^^^^^^^ |
| 64 | + |
| 65 | +Executes the raw HTTP requests to the Reddit API, handling the low-level communication details. |
| 66 | + |
| 67 | +**Related Classes/Methods**: |
| 68 | + |
| 69 | +* `praw.reddit.Reddit.request <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 70 | + |
| 71 | +Response Objectifier |
| 72 | +^^^^^^^^^^^^^^^^^^^^ |
| 73 | + |
| 74 | +Transforms the raw JSON responses from the API into structured PRAW Python objects, making them easier to consume and work with. |
| 75 | + |
| 76 | +**Related Classes/Methods**: |
| 77 | + |
| 78 | +* `praw.reddit.Reddit._objectify_request <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 79 | + |
| 80 | +Rate Limit Manager |
| 81 | +^^^^^^^^^^^^^^^^^^ |
| 82 | + |
| 83 | +Monitors and enforces Reddit's API rate limits, pausing requests when necessary to prevent exceeding usage quotas and ensuring compliance. |
| 84 | + |
| 85 | +**Related Classes/Methods**: |
| 86 | + |
| 87 | +* `praw.reddit.Reddit._handle_rate_limit <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 88 | + |
| 89 | +API Operation Methods |
| 90 | +^^^^^^^^^^^^^^^^^^^^^ |
| 91 | + |
| 92 | +Provide specific, high-level methods for common API operations (e.g., fetching data, creating posts, deleting resources), abstracting the underlying request and response handling details from the end-user. |
| 93 | + |
| 94 | +**Related Classes/Methods**: |
| 95 | + |
| 96 | +* `praw.reddit.Reddit.get <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 97 | +* `praw.reddit.Reddit.post <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 98 | +* `praw.reddit.Reddit.delete <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 99 | +* `praw.reddit.Reddit.patch <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 100 | +* `praw.reddit.Reddit.put <https://github.com/praw-dev/praw/blob/main/praw/reddit.py>`_ |
| 101 | + |
| 102 | +Async Checker |
| 103 | +^^^^^^^^^^^^^ |
| 104 | + |
| 105 | +Manages and verifies the asynchronous context for operations, ensuring proper execution in async environments. |
| 106 | + |
| 107 | +**Related Classes/Methods**: |
| 108 | + |
| 109 | +* `praw.reddit._check_for_async:388-411 <https://github.com/praw-dev/praw/blob/main/praw/reddit.py#L388-L411>`_ |
| 110 | + |
| 111 | + |
| 112 | +FAQ |
| 113 | +--- |
| 114 | + |
| 115 | +`See the FAQ <https://github.com/CodeBoarding/GeneratedOnBoardings/tree/main?tab=readme-ov-file#faq>`_ |
0 commit comments