# The Reddit Instance

class `praw.``Reddit`(site_name=None, requestor_class=None, requestor_kwargs=None, **config_settings)

  The Reddit class provides convenient access to reddit’s API.

  Instances of this class are the gateway to interacting with Reddit’s API through PRAW. The canonical way to obtain an instance of this class is via:

      import praw
      reddit = praw.Reddit(client_id='CLIENT_ID',
                           client_secret="CLIENT_SECRET", password='PASSWORD',
                           user_agent='USERAGENT', username='USERNAME')

  `__init__`(site_name=None, requestor_class=None, requestor_kwargs=None, **config_settings)

    Initialize a Reddit instance.

    Parameters:

    - site_name – The name of a section in your `praw.ini` file from which to load settings from. This parameter, in tandem with an appropriately configured `praw.ini`, file is useful if you wish to easily save credentials for different applications, or communicate with other servers running reddit. If `site_name` is `None`, then the site name will be looked for in the environment variable praw_site. If it is not found there, the DEFAULT site will be used.
    - requestor_class – A class that will be used to create a requestor. If not set, use `prawcore.Requestor` (default: None).
    - requestor_kwargs – Dictionary with additional keyword arguments used to initialize the requestor (default: None).

    Additional keyword arguments will be used to initialize the :class`.Config` object. This can be used to specify configuration settings during instantiation of the `Reddit` instance. For more details please see Configuring PRAW.

    Required settings are:

    - client_id
    - client_secret (for installed applications set this value to `None`)
    - user_agent

    The `requestor_class` and `requestor_kwargs` allow for customization of the requestor :class`.Reddit` will use. This allows, e.g., easily adding behavior to the requestor or wrapping its :class`Session` in a caching layer. Example usage:

        import json, betamax, requests

        class JSONDebugRequestor(Requestor):
            def request(self, *args, **kwargs):
                response = super().request(*args, **kwargs)
                print(json.dumps(response.json(), indent=4))
                return response

        my_session = betamax.Betamax(requests.Session())
        reddit = Reddit(..., requestor_class=JSONDebugRequestor,
                        requestor_kwargs={'session': my_session})

  `auth` = None

    An instance of `Auth`.

    Provides the interface for interacting with installed and web applications. See Obtain the Authorization URL

  `comment`(id=None, url=None)

    Return a lazy instance of `Comment` for `id`.

    Parameters:

    - id – The ID of the comment.
    - url – A permalink pointing to the comment.

    Note

    If you want to obtain the comment’s replies, you will need to call `refresh()` on the returned `Comment`.

  `domain`(domain)

    Return an instance of `DomainListing`.

    Parameters: | domain – The domain to obtain submission listings for.

  `front` = None

    An instance of `Front`.

    Provides the interface for interacting with front page listings. For example:

        for submission in reddit.front.hot():
            print(submission)

  `get`(path, params=None)

    Return parsed objects returned from a GET request to `path`.

    Parameters:

    - path – The path to fetch.
    - params – The query parameters to add to the request (default: None).

  `inbox` = None

    An instance of `Inbox`.

    Provides the interface to a user’s inbox which produces `Message`, `Comment`, and `Submission` instances. For example to iterate through comments which mention the authorized user run:

        for comment in reddit.inbox.mentions():
            print(comment)

  `info`(fullnames=None, url=None)

    Fetch information about each item in `fullnames` or from `url`.

    Parameters:

    - fullnames – A list of fullnames for comments, submissions, and/or subreddits.
    - url – A url (as a string) to retrieve lists of link submissions from.

    Returns: | A generator that yields found items in their relative order.

    Items that cannot be matched will not be generated. Requests will be issued in batches for each 100 fullnames.

    Note

    For comments that are retrieved via this method, if you want to obtain its replies, you will need to call `refresh()` on the yielded `Comment`.

    Note

    When using the URL option, it is important to be aware that URLs are treated literally by Reddit’s API. As such, the URLs “youtube.com” and “https://www.youtube.com” will provide a different set of submissions.

  `live` = None

    An instance of `LiveHelper`.

    Provides the interface for working with `LiveThread` instances. At present only new LiveThreads can be created.

        reddit.live.create('title', 'description')

  `multireddit` = None

    An instance of `MultiredditHelper`.

    Provides the interface to working with `Multireddit` instances. For example you can obtain a `Multireddit` instance via:

        reddit.multireddit('samuraisam', 'programming')

  `patch`(path, data=None)

    Return parsed objects returned from a PATCH request to `path`.

    Parameters:

    - path – The path to fetch.
    - data – Dictionary, bytes, or file-like object to send in the body of the request (default: None).

  `post`(path, data=None, files=None, params=None)

    Return parsed objects returned from a POST request to `path`.

    Parameters:

    - path – The path to fetch.
    - data – Dictionary, bytes, or file-like object to send in the body of the request (default: None).
    - files – Dictionary, filename to file (like) object mapping (default: None).
    - params – The query parameters to add to the request (default: None).

  `put`(path, data=None)

    Return parsed objects returned from a PUT request to `path`.

    Parameters:

    - path – The path to fetch.
    - data – Dictionary, bytes, or file-like object to send in the body of the request (default: None).

  `random_subreddit`(nsfw=False)

    Return a random lazy instance of `Subreddit`.

    Parameters: | nsfw – Return a random NSFW (not safe for work) subreddit (default: False).

  `read_only`

    Return True when using the ReadOnlyAuthorizer.

  `redditor`(name)

    Return a lazy instance of `Redditor` for `name`.

    Parameters: | name – The name of the redditor.

  `redditors` = None

    An instance of `Redditors`.

    Provides the interface for Redditor discovery. For example to iterate over the newest Redditors, run:

        for redditor in reddit.redditors.new(limit=None):
            print(redditor)

  `request`(method, path, params=None, data=None, files=None)

    Return the parsed JSON data returned from a request to URL.

    Parameters:

    - method – The HTTP method (e.g., GET, POST, PUT, DELETE).
    - path – The path to fetch.
    - params – The query parameters to add to the request (default: None).
    - data – Dictionary, bytes, or file-like object to send in the body of the request (default: None).
    - files – Dictionary, filename to file (like) object mapping (default: None).

  `submission`(id=None, url=None)

    Return a lazy instance of `Submission`.

    Parameters:

    - id – A reddit base36 submission ID, e.g., `2gmzqe`.
    - url – A URL supported by `id_from_url()`.`.

    Either `id` or `url` can be provided, but not both.

  `subreddit` = None

    An instance of `SubredditHelper`.

    Provides the interface to working with `Subreddit` instances. For example to create a Subreddit run:

        reddit.subreddit.create('coolnewsubname')

    To obtain a lazy a `Subreddit` instance run:

        reddit.subreddit('redditdev')

    Note that multiple subreddits can be combined and filtered views of /r/all can also be used just like a subreddit:

        reddit.subreddit('redditdev+learnpython+botwatch')
        reddit.subreddit('all-redditdev-learnpython')

  `subreddits` = None

    An instance of `Subreddits`.

    Provides the interface for `Subreddit` discovery. For example to iterate over the set of default subreddits run:

        for subreddit in reddit.subreddits.default(limit=None):
            print(subreddit)

  `user` = None

    An instance of `User`.

    Provides the interface to the currently authorized `Redditor`. For example to get the name of the current user run:

        print(reddit.user.me())

Helper Classes

- reddit.front
- reddit.inbox
- reddit.live
- reddit.multireddit
- reddit.redditors
- reddit.subreddit
- reddit.subreddits
- reddit.user