py-reddit package¶
Contents of reddit¶
- class reddit.AsyncClient(agent, key)[source]¶
Bases:
objectRepresents an asynchronous Client for fetching reddit posts.
- class Subreddit(*args, **kwargs)[source]¶
Bases:
objectGets the raw data on a subreddit, which can be fetched via the various methods here.
- Parameters
name (str) – The name of the subreddit
mode (str) – ‘top’, ‘hot’, or ‘new’ kind of posts
limit (int) – The number of posts to fetch, defaults to 25 if not specified
- async author(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
author – The author of a post at the specified index.
- Return type
str
- async downvotes(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
downvotes – The number of downvotes in a post at the specified index.
- Return type
str
- async image(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
image – The image url in a post at the specified index.
- Return type
str
- Raises
KeyError – If the post at the specified index does not have an image.
- async num_comments(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
num_comments – The number of comments in a post at the specified index.
- Return type
str
- async permalink(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
permalink – The permalink of a post at the specified index.
- Return type
str
- async post_url(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
post_url – The url of a post at the specified index.
- Return type
str
- async score(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
score – The score of a post (upvotes-downvotes) at the specified index.
- Return type
str
- async selftext(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
selftext – The selftext of a post at the specified index.
- Return type
str
- class reddit.Client(agent, key)[source]¶
Bases:
objectRepresents a synchronous Client for fetching reddit posts.
- class Subreddit(mode, name, limit: int = 25)[source]¶
Bases:
objectGets the raw data on a subreddit, which can be fetched via the various methods here.
- Parameters
name (str) – The name of the subreddit
mode (str) – ‘top’, ‘hot’, or ‘new’ kind of posts
limit (int) – The number of posts to fetch, defaults to 25 if not specified
- author(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
author – The author of a post at the specified index.
- Return type
str
- downvotes(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
downvotes – The number of downvotes in a post at the specified index.
- Return type
str
- image(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
image – The image url in a post at the specified index.
- Return type
str
- Raises
KeyError – Raised if there’s no image in the post.
- num_comments(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
num_comments – The number of comments of a post at the specified index.
- Return type
str
- permalink(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
permalink – The permalink of a post at the specified index.
- Return type
str
- post_url(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
post_url – The url of a post at the specified index.
- Return type
str
- score(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
score – The score (upvotes-downvotes) of a post at the specified index.
- Return type
str
- selftext(index: int)[source]¶
- Parameters
index (int) – The index of the post to fetch (first post is marked as 0)
- Returns
selftext – The selftext of a post at the specified index.
- Return type
str