get_top_posts
Retrieve the most popular posts from a specific subreddit based on your chosen time filter and limit, providing structured data including post details like title, author, score, and comments.
Instructions
Get top posts from a subreddit.
Args:
subreddit: Name of the subreddit (with or without 'r/' prefix)
time_filter: Time period to filter posts (e.g. "day", "week", "month", "year", "all")
limit: Number of posts to fetch (1-100)
Returns:
Dictionary containing structured post information with the following structure:
{
'subreddit': str, # Subreddit name
'time_filter': str, # The time period used for filtering
'posts': [ # List of posts, each with the following structure:
{
'id': str, # Post ID
'title': str, # Post title
'author': str, # Author's username
'score': int, # Post score (upvotes - downvotes)
'upvote_ratio': float, # Ratio of upvotes to total votes
'num_comments': int, # Number of comments
'created_utc': float, # Post creation timestamp
'url': str, # URL to the post
'permalink': str, # Relative URL to the post
'is_self': bool, # Whether it's a self (text) post
'selftext': str, # Content of self post (if any)
'link_url': str, # URL for link posts (if any)
'over_18': bool, # Whether marked as NSFW
'spoiler': bool, # Whether marked as spoiler
'stickied': bool, # Whether stickied in the subreddit
'locked': bool, # Whether comments are locked
'distinguished': Optional[str], # Distinguishing type (e.g., 'moderator')
'flair': Optional[Dict], # Post flair information if any
},
...
],
'metadata': {
'fetched_at': float, # Timestamp when data was fetched
'post_count': int, # Number of posts returned
}
}
Raises:
ValueError: If subreddit is invalid or time_filter is not valid
RuntimeError: For other errors during the operation
Input Schema
Name | Required | Description | Default |
---|---|---|---|
limit | No | ||
subreddit | Yes | ||
time_filter | No | week |
Input Schema (JSON Schema)
{
"properties": {
"limit": {
"default": 10,
"title": "Limit",
"type": "integer"
},
"subreddit": {
"title": "Subreddit",
"type": "string"
},
"time_filter": {
"default": "week",
"title": "Time Filter",
"type": "string"
}
},
"required": [
"subreddit"
],
"title": "get_top_postsArguments",
"type": "object"
}