User

This section describes User class as well as AuthenticatedUser that contain information about the logged-in user and request credentials.

class apraw.models.User(reddit: Reddit, username: str, password: str, client_id: str, client_secret: str, user_agent: str)

A class to store the authentication credentials and handle ratelimit information.

reddit: Reddit
The Reddit instance with which requests are made.
username: str
The username given to the Reddit instance or obtained via praw.ini.
password: str
The password given to the Reddit instance or obtained via praw.ini.
client_id: str
The client ID given to the Reddit instance or obtained via praw.ini.
client_secret: str
The client secret given to the Reddit instance or obtained via praw.ini.
user_agent: str
The user agent given to the Reddit instance or defaulted to aPRAW’s version.
password_grant: str
The data to be used when making a token request with the ‘password’ grant_type.
access_data: Dict
A dictionary containing the access token and user agent for request headers.
token_expires: datetime
The datetime on which the previously retrieved token will expire. Defaults to the past to obtain a token immediately the first time.
ratelimit_remaining: int
The number of requests remaining in the current ratelimit window.
ratelimit_used: int
The number of requests previously used in the current ratelimit window.
ratelimit_reset: datetime
The datetime on which the ratelimit window will be reset.
get_auth_session() → aiohttp.client.ClientSession

Retrieve an aiohttp.ClientSesssion with which the authentication token can be obtained.

Returns:session – The session using the BasicAuth setup to obtain tokens with.
Return type:aiohttp.ClientSession
get_client_session() → aiohttp.client.ClientSession

Retrieve the aiohttp.ClientSesssion with which regular requests are made.

Returns:session – The session with which requests should be made.
Return type:aiohttp.ClientSession
me() → apraw.models.user.AuthenticatedUser

Retrieve an instance of AuthenticatedUser for the logged-in user.

Returns:user – The logged-in user.
Return type:AuthenticatedUser

AuthenticatedUser

class apraw.models.AuthenticatedUser(reddit: Reddit, data: Dict)

The model representing the logged-in user.

This model inherits from Redditor and thus all its attributes and features. View those docs for further information.

reddit: Reddit
The Reddit instance with which requests are made.
data: Dict
The data obtained from the /about endpoint.
karma() → List[apraw.models.user.Karma]

Retrieve the karma breakdown for the logged-in user.

Returns:karma – The parsed KarmaList for the logged-in user.
Return type:List[Karma]

Karma

The Karma model represents items in a KarmaList and contains information about the subreddit the karma was obtained on, as well as the amount of link and comment karma.

class apraw.models.Karma(reddit: Reddit, data: Dict)

A model representing subreddit karma.

reddit: Reddit
The Reddit instance with which requests are made.
data: Dict
The data obtained from the /about endpoint.

Typical Attributes

This table describes attributes that typically belong to objects of this class. Attributes are dynamically provided by the aPRAWBase class and may vary depending on the status of the response and expected objects.

Attribute Description
sr The name of the subreddit the karma was obtained on
comment_karma The amount of karma obtained on the subreddit.
link_karma The amount of link karma obtained on the subreddit.
subreddit()

Retrieve the subreddit on which the karma was obtained.

Returns:subreddit – The subreddit on which the karma was obtained.
Return type:Subreddit