5 min read

Documentation for searchPosts Logic

Overview

This node in the Vantage analytics and data platform is designed to facilitate the retrieval of posts from Reddit based on user-defined search parameters. This component connects to the Reddit API to perform searches, allowing users to specify criteria such as query terms, subreddit, sorting options, and a limit on the number of posts returned.

Purpose

The primary purpose of this node is to enable users to generate targeted search queries for Reddit posts. By utilizing the input parameters, users can customize their queries to return relevant posts from specific subreddits, or sort them based on different criteria, resulting in more efficient data gathering and analysis.

Settings

Input Parameters

This node accepts the following input parameters:

  1. query

    • Input Type: String
    • Description: This parameter is mandatory and represents the search term. The logic will return posts that include this term.
    • Default Value: '' (empty string)
    • Behavior: If this parameter is not provided, the logic will return an error stating that a search query is required.
  2. subreddit

    • Input Type: String
    • Description: This optional parameter specifies which subreddit to search within. If provided, the search will be limited to this subreddit.
    • Default Value: '' (empty string)
    • Behavior: If this parameter is empty, posts from all subreddits will be considered in the search.
  3. sort

    • Input Type: String
    • Description: This parameter determines the sorting order of the search results. It can be set to options such as 'relevance', 'hot', 'new', or 'top'.
    • Default Value: 'relevance'
    • Behavior: Changing this value will alter the ordering of posts returned, which can be crucial for finding the most pertinent content.
  4. time

    • Input Type: String
    • Description: This optional parameter specifies the time frame for viewing posts. Acceptable values include 'all', 'day', 'hour', 'month', and 'year'.
    • Default Value: 'all'
    • Behavior: Modifying this parameter affects the temporal relevance of the posts returned, filtering based on when they were created.
  5. limit

    • Input Type: Numeric
    • Description: This parameter sets the maximum number of posts to be returned in the API response.
    • Default Value: 25
    • Behavior: Adjusting this value will increase or decrease the number of posts fetched, which can impact performance and response time.
  6. after

    • Input Type: String or undefined
    • Description: This optional parameter is used for pagination, allowing users to retrieve posts that come after a specific item in the results.
    • Default Value: undefined
    • Behavior: If provided, it will load the next set of posts based on the current dataset returned by the API, enabling more extensive searches across multiple pages of results.

How It Works

The node initiates by extracting the input parameters from either the inputs or config arguments provided by the calling context, falling back to default values as necessary. The logic will check for the mandatory query parameter and return an error if it is not defined.

Next, it uses the the integration connection function to create an integration instance with Reddit’s API, which allows for executing the search operation. After successful integration, a search is performed using the specified parameters.

The results, which are structured according to Reddit’s API format, are then processed to extract the relevant post details. The final output includes an array of posts along with pagination data, which helps in managing requests for large datasets.

In case of errors during the API call, a detailed error message will be returned to assist in debugging.

AI Integrations

Currently, this node integrates solely with Reddit. There are no AI integrations included within the logic itself. However, the data retrieved could be utilized within AI or machine learning models for sentiment analysis, topic modeling, or trend identification based on the Reddit posts obtained.

Billing Impacts

Using this node might impact billing depending on the number of requests sent to the Reddit API and the amount of data processed. Users should be aware that excessive querying, especially with high limits, could lead to potential cost variations based on their subscription plan. Monitoring API call limits is advised to align with the billing cycle.

Use Cases & Examples

Use Cases

  1. Market Research: A market analyst could use this node to pull posts related to a specific product or brand from a particular subreddit. This would enable them to gauge the public sentiment about the product and make data-driven recommendations.

  2. Content Creation: A content marketing team can leverage this component to find trending topics or discussions within their industry by searching relevant subreddits, helping them create fresh and engaging content tailored to audience interests.

  3. Social Listening: Companies can implement this logic to monitor discussions about their brand or competitors, enabling timely responses to customer feedback or inquiries as they arise on Reddit.

Example Configuration

Use Case: Market Research for Product Sentiment Analysis

Configuration Data:

json
{
    "inputs": {
        "query": "Gadget X review",
        "subreddit": "Gadgets",
        "sort": "new",
        "time": "month",
        "limit": 50
    },
    "config": {}
}

Explanation: In this configuration, the user is interested in gathering recent reviews for "Gadget X" from the "Gadgets" subreddit. By sorting results by 'new' and limiting the response to 50 posts, the user can efficiently analyze the latest discussions to understand consumer sentiments and feedback regarding the gadget.