docs/integrations/app-integrations/reddit.mdx
In this section, we present how to connect Reddit to MindsDB.
Reddit is a social media platform and online community where registered users can engage in discussions, share content, and participate in various communities called subreddits.
Data from Reddit can be utilized within MindsDB to train AI models and chatbots.
Before proceeding, ensure the following prerequisites are met:
This handler is implemented using the PRAW (Python Reddit API Wrapper) library, which is a Python package that provides a simple and easy-to-use interface to access the Reddit API.
The required arguments to establish a connection are as follows:
client_id is a Reddit API client ID.client_secret is a Reddit API client secret.user_agent is a user agent string to identify your application.CLIENT_ID, CLIENT_SECRET, and USER_AGENT, respectively.
</Tip>
In order to make use of this handler and connect the Reddit app to MindsDB, the following syntax can be used:
CREATE DATABASE my_reddit
WITH
ENGINE = 'reddit',
PARAMETERS = {
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET",
"user_agent": "YOUR_USER_AGENT"
};
It creates a database that comes with two tables: submission and comment.
Now you can fetch data from Reddit, like this:
SELECT *
FROM my_reddit.submission
WHERE subreddit = 'MachineLearning'
AND sort_type = 'top' -- specifies the sorting type for the subreddit (possible values include 'hot', 'new', 'top', 'controversial', 'gilded', 'wiki', 'mod', 'rising')
AND items = 5; -- specifies the number of items to fetch from the subreddit
You can also fetch comments for a particular post/submission, like this:
SELECT *
FROM my_reddit.comment
WHERE submission_id = '12gls93'