add fetch_subreddit endpoint to retrieve and insert top posts from a specified subreddit

This commit is contained in:
2026-01-11 15:07:44 +00:00
parent d3c985ba1f
commit 4b8aebd312
2 changed files with 24 additions and 0 deletions

View File

@@ -18,6 +18,15 @@ class RedditConnector(BaseConnector):
data = self._fetch_data(url, params)
return self._parse_posts(data)
def get_top_subreddit_posts(self, subreddit: str, limit: int = 10, timeframe: str = 'day') -> list[Post]:
params = {
'limit': limit,
't': timeframe
}
url = f"r/{subreddit}/top.json"
data = self._fetch_data(url, params)
return self._parse_posts(data)
def search_posts(self,
search: str,
limit: int = 10,