5 min read

Documentation for getUserHistory

Purpose

The node is designed to retrieve the historical activity of a specified Reddit user. It provides details about posts, comments, and other interactions the user has had on the platform. This logic interfaces with the Reddit API to fetch and format the user's history, allowing for further analysis or display within the Vantage analytics & data platform.

Settings

This node includes several configurable settings that optimize its performance and control the output. Each setting is explained below:

1. username

2. where

3. sort

4. time

5. limit

6. after

How It Works

The node retrieves user history in the following way:

  1. Input Handling: It checks for the defined inputs in a specific order (from inputs, then from config, with defaults as a fallback) to set up the necessary parameters.

  2. Validation: It validates the existence of the username parameter. If it is missing, an error response is immediately returned.

  3. Integration Setup: The function makes use of the integration connection to establish a connection to the Reddit API, passing the necessary context.

  4. API Call: It sends a request to the Reddit API to retrieve user history based on the collected parameters, including specified filters and pagination controls.

  5. Data Formatting: The response data from Reddit is processed, flattening the structure to a more manageable format, which extracts essential elements for output.

  6. Error Handling: It includes a try-catch block to manage potential errors while interacting with the API, ensuring that appropriate error messages are returned.

  7. Output Generation: Finally, it returns structured output containing the processed user history, including a count of items and pagination information (if applicable).

Data Expectations

This node expects the following data inputs:

If the username is not provided, the function cannot execute, returning an error message instead.

Use Cases & Examples

Use Case 1: User Engagement Analysis

A business can use getUserHistory to analyze a specific user's engagement on Reddit. Understanding what posts or comments a user interacts with can provide insights into their interests and preferences.

Use Case 2: Community Management

Moderators of a subreddit can utilize this logic to review user contributions. By analyzing user history, moderators can identify valuable contributors or problem users for more tailored community management.

Use Case 3: Content Marketing Strategy

A marketing team may employ this function to track influencers' activities across Reddit, understanding how they engage with content relevant to their brand. This can guide partnerships and marketing campaigns.

Example Configuration

For the second use case, reviewing a user’s comments in the last month, the configuration of getUserHistory could look like this:

json
{
  "inputs": {
    "username": "exampleUser",
    "where": "comments",
    "sort": "new",
    "time": "month",
    "limit": 50
  },
  "config": {},
  "context": { "apiKey": "your_api_key_here" }
}

In this configuration:

This setup will return recent comments made by exampleUser, essential for evaluating engagement trends within specific content discussions.