Preferences
- class praw.models.Preferences(reddit: praw.Reddit)
A class for Reddit preferences.
The
Preferences
class provides access to the Reddit preferences of the currently authenticated user.- __call__() Dict[str, Union[str, int, bool]]
Return the preference settings of the authenticated user as a dict.
This method is intended to be accessed as
reddit.user.preferences()
like so:preferences = reddit.user.preferences() print(preferences["show_link_flair"])
See https://www.reddit.com/dev/api#GET_api_v1_me_prefs for the list of possible values.
- __init__(reddit: praw.Reddit)
Initialize a
Preferences
instance.- Parameters
reddit – The
Reddit
instance.
- update(**preferences: Union[bool, int, str])
Modify the specified settings.
- Parameters
accept_pms – Who can send you personal messages (one of
"everyone"
or"whitelisted"
).activity_relevant_ads – Allow Reddit to use your activity on Reddit to show you more relevant advertisements.
allow_clicktracking – Allow Reddit to log my outbound clicks for personalization.
beta – I would like to beta test features for Reddit.
clickgadget – Show me links I’ve recently viewed.
collapse_read_messages – Collapse messages after I’ve read them.
compress – Compress the link display.
creddit_autorenew – Use a creddit to automatically renew my gold if it expires.
default_comment_sort – Default comment sort (one of
"confidence"
,"top"
,"new"
,"controversial"
,"old"
,"random"
,"qa"
, or"live"
).domain_details (bool) – Show additional details in the domain text when available, such as the source subreddit or the content author’s url/name.
email_chat_request (bool) – Send chat requests as emails.
email_comment_reply (bool) – Send comment replies as emails.
email_digests (bool) – Send email digests.
email_messages (bool) – Send messages as emails.
email_post_reply (bool) – Send post replies as emails.
email_private_message (bool) – Send private messages as emails.
email_unsubscribe_all (bool) – Unsubscribe from all emails.
email_upvote_comment (bool) – Send comment upvote updates as emails.
email_upvote_post (bool) – Send post upvote updates as emails.
email_user_new_follower (bool) – Send new follower alerts as emails.
email_username_mention (bool) – Send username mentions as emails.
enable_default_themes (bool) – Use Reddit theme.
feed_recommendations_enabled (bool) – Enable feed recommendations.
geopopular (str) – Location (one of
"GLOBAL"
,"AR"
,"AU"
,"BG"
,"CA"
,"CL"
,"CO"
,"CZ"
,"FI"
,"GB"
,"GR"
,"HR"
,"HU"
,"IE"
,"IN"
,"IS"
,"JP"
,"MX"
,"MY"
,"NZ"
,"PH"
,"PL"
,"PR"
,"PT"
,"RO"
,"RS"
,"SE"
,"SG"
,"TH"
,"TR"
,"TW"
,"US"
,"US_AK"
,"US_AL"
,"US_AR"
,"US_AZ"
,"US_CA"
,"US_CO"
,"US_CT"
,"US_DC"
,"US_DE"
,"US_FL"
,"US_GA"
,"US_HI"
,"US_IA"
,"US_ID"
,"US_IL"
,"US_IN"
,"US_KS"
,"US_KY"
,"US_LA"
,"US_MA"
,"US_MD"
,"US_ME"
,"US_MI"
,"US_MN"
,"US_MO"
,"US_MS"
,"US_MT"
,"US_NC"
,"US_ND"
,"US_NE"
,"US_NH"
,"US_NJ"
,"US_NM"
,"US_NV"
,"US_NY"
,"US_OH"
,"US_OK"
,"US_OR"
,"US_PA"
,"US_RI"
,"US_SC"
,"US_SD"
,"US_TN"
,"US_TX"
,"US_UT"
,"US_VA"
,"US_VT"
,"US_WA"
,"US_WI"
,"US_WV"
, or"US_WY"
).hide_ads (bool) – Hide ads.
hide_downs (bool) – Don’t show me submissions after I’ve downvoted them, except my own.
hide_from_robots (bool) – Don’t allow search engines to index my user profile.
hide_ups (bool) – Don’t show me submissions after I’ve upvoted them, except my own.
highlight_controversial (bool) – Show a dagger on comments voted controversial.
highlight_new_comments (bool) – Highlight new comments.
ignore_suggested_sort (bool) – Ignore suggested sorts.
in_redesign_beta (bool) – In redesign beta.
label_nsfw (bool) – Label posts that are not safe for work.
lang (str) – Interface language (IETF language tag, underscore separated).
legacy_search (bool) – Show legacy search page.
live_orangereds (bool) – Send message notifications in my browser.
mark_messages_read (bool) – Mark messages as read when I open my inbox.
media (str) – Thumbnail preference (one of
"on"
,"off"
, or"subreddit"
).media_preview (str) – Media preview preference (one of
"on"
,"off"
, or"subreddit"
).min_comment_score (int) – Don’t show me comments with a score less than this number (between
-100
and100
).min_link_score (int) – Don’t show me submissions with a score less than this number (between
-100
and100
).monitor_mentions (bool) – Notify me when people say my username.
newwindow (bool) – Open links in a new window.
nightmode (bool) – Enable night mode.
no_profanity (bool) – Don’t show thumbnails or media previews for anything labeled NSFW.
num_comments (int) – Display this many comments by default (between
1
and500
).numsites (int) – Number of links to display at once (between
1
and100
).organic (bool) – Show the spotlight box on the home feed.
other_theme (str) – Subreddit theme to use (subreddit name).
over_18 (bool) – I am over eighteen years old and willing to view adult content.
private_feeds (bool) – Enable private RSS feeds.
profile_opt_out (bool) – View user profiles on desktop using legacy mode.
public_votes (bool) – Make my votes public.
research (bool) – Allow my data to be used for research purposes.
search_include_over_18 (bool) – Include not safe for work (NSFW) search results in searches.
send_crosspost_messages (bool) – Send crosspost messages.
send_welcome_messages (bool) – Send welcome messages.
show_flair (bool) – Show user flair.
show_gold_expiration (bool) – Show how much gold you have remaining on your userpage.
show_link_flair (bool) – Show link flair.
show_location_based_recommendations (bool) – Show location based recommendations.
show_presence (bool) – Show presence.
show_promote (bool) – Show promote.
show_stylesheets (bool) – Allow subreddits to show me custom themes.
show_trending (bool) – Show trending subreddits on the home feed.
show_twitter (bool) – Show a link to your Twitter account on your profile.
store_visits (bool) – Store visits.
theme_selector (bool) – Theme selector (subreddit name).
third_party_data_personalized_ads (bool) – Allow Reddit to use data provided by third-parties to show you more relevant advertisements on Reddit.
third_party_personalized_ads (bool) – Allow personalization of advertisements.
third_party_site_data_personalized_ads (bool) – Allow personalization of advertisements using third-party website data.
third_party_site_data_personalized_content (bool) – Allow personalization of content using third-party website data.
threaded_messages (bool) – Show message conversations in the inbox.
threaded_modmail (bool) – Enable threaded modmail display.
top_karma_subreddits (bool) – Top karma subreddits.
use_global_defaults (bool) – Use global defaults.
video_autoplay (bool) – Autoplay Reddit videos on the desktop comments page.
Additional keyword arguments can be provided to handle new settings as Reddit introduces them.
See https://www.reddit.com/dev/api#PATCH_api_v1_me_prefs for the most up-to-date list of possible parameters.
This is intended to be used like so:
reddit.user.preferences.update(show_link_flair=True)
This method returns the new state of the preferences as a
dict
, which can be used to check whether a change went through.original_preferences = reddit.user.preferences() new_preferences = reddit.user.preferences.update(invalid_param=123) print(original_preferences == new_preferences) # True, no change
Warning
Passing an unknown parameter name or an illegal value (such as an int when a boolean is expected) does not result in an error from the Reddit API. As a consequence, any invalid input will fail silently. To verify that changes have been made, use the return value of this method, which is a dict of the preferences after the update action has been performed.
Some preferences have names that are not valid keyword arguments in Python. To update these, construct a
dict
and use**
to unpack it as keyword arguments:reddit.user.preferences.update(**{"third_party_data_personalized_ads": False})