Preferences¶
-
class
praw.models.Preferences(reddit: Reddit)¶ A class for Reddit preferences.
The Preferences class provides access to the Reddit preferences of the currently authenticated user.
-
__call__() → Dict[str, Union[bool, int, str]]¶ 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: Reddit)¶ Create 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,whitelisted).activity_relevant_ads – Allow Reddit to use your activity on Reddit to show you more relevant advertisements (boolean).
allow_clicktracking – Allow Reddit to log my outbound clicks for personalization (boolean).
beta – I would like to beta test features for Reddit (boolean).
clickgadget – Show me links I’ve recently viewed (boolean).
collapse_read_messages – Collapse messages after I’ve read them (boolean).
compress – Compress the link display (boolean).
creddit_autorenew – Use a creddit to automatically renew my gold if it expires (boolean).
default_comment_sort – Default comment sort (one of
"confidence","top","new","controversial","old","random","qa","live").domain_details – Show additional details in the domain text when available, such as the source subreddit or the content author’s url/name (boolean).
email_chat_request – Send chat requests as emails (boolean).
email_comment_reply – Send comment replies as emails (boolean).
email_digests – Send email digests (boolean).
email_messages – Send messages as emails (boolean).
email_post_reply – Send post replies as emails (boolean).
email_private_message – Send private messages as emails (boolean).
email_unsubscribe_all – Unsubscribe from all emails (boolean).
email_upvote_comment – Send comment upvote updates as emails (boolean).
email_upvote_post – Send post upvote updates as emails (boolean).
email_user_new_follower – Send new follower alerts as emails (boolean).
email_username_mention – Send username mentions as emails (boolean).
enable_default_themes – Use reddit theme (boolean).
feed_recommendations_enabled – Enable feed recommendations (boolean).
geopopular – 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","US_WY").hide_ads – Hide ads (boolean).
hide_downs – Don’t show me submissions after I’ve downvoted them, except my own (boolean).
hide_from_robots – Don’t allow search engines to index my user profile (boolean).
hide_ups – Don’t show me submissions after I’ve upvoted them, except my own (boolean).
highlight_controversial – Show a dagger on comments voted controversial (boolean).
highlight_new_comments – Highlight new comments (boolean).
ignore_suggested_sort – Ignore suggested sorts (boolean).
in_redesign_beta – In redesign beta (boolean).
label_nsfw – Label posts that are not safe for work (boolean).
lang – Interface language (IETF language tag, underscore separated).
legacy_search – Show legacy search page (boolean).
live_orangereds – Send message notifications in my browser (boolean).
mark_messages_read – Mark messages as read when I open my inbox (boolean).
media – Thumbnail preference (one of
"on","off","subreddit").media_preview – Media preview preference (one of
"on","off","subreddit").min_comment_score – Don’t show me comments with a score less than this number (int between
-100and100).min_link_score – Don’t show me submissions with a score less than this number (int between
-100and100).monitor_mentions – Notify me when people say my username (boolean).
newwindow – Open links in a new window (boolean).
nightmode – Enable night mode (boolean).
no_profanity – Don’t show thumbnails or media previews for anything labeled NSFW (boolean).
num_comments – Display this many comments by default (int between
1and500).numsites – Number of links to display at once (int between
1and100).organic – Show the spotlight box on the home feed (boolean).
other_theme – Subreddit theme to use (subreddit name).
over_18 – I am over eighteen years old and willing to view adult content (boolean).
private_feeds – Enable private RSS feeds (boolean).
profile_opt_out – View user profiles on desktop using legacy mode (boolean).
public_votes – Make my votes public (boolean).
research – Allow my data to be used for research purposes (boolean).
search_include_over_18 – Include not safe for work (NSFW) search results in searches (boolean).
send_crosspost_messages – Send crosspost messages (boolean).
send_welcome_messages – Send welcome messages (boolean).
show_flair – Show user flair (boolean).
show_gold_expiration – Show how much gold you have remaining on your userpage (boolean).
show_link_flair – Show link flair (boolean).
show_location_based_recommendations – Show location based recommendations (boolean).
show_presence – Show presence (boolean).
show_promote – Show promote (boolean).
show_stylesheets – Allow subreddits to show me custom themes (boolean).
show_trending – Show trending subreddits on the home feed (boolean).
show_twitter – Show a link to your Twitter account on your profile (boolean).
store_visits – Store visits (boolean).
theme_selector – Theme selector (subreddit name).
third_party_data_personalized_ads – Allow Reddit to use data provided by third-parties to show you more relevant advertisements on Reddit (boolean).
third_party_personalized_ads – Allow personalization of advertisements (boolean).
third_party_site_data_personalized_ads – Allow personalization of advertisements using third-party website data (boolean).
third_party_site_data_personalized_content – Allow personalization of content using third-party website data (boolean).
threaded_messages – Show message conversations in the inbox ( boolean).
threaded_modmail – Enable threaded modmail display (boolean).
top_karma_subreddits – Top karma subreddits (boolean).
use_global_defaults – Use global defaults (boolean).
video_autoplay – Autoplay Reddit videos on the desktop comments page (boolean).
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
dictand use**to unpack it as keyword arguments:reddit.user.preferences.update(**{"third_party_data_personalized_ads": False})
-