Skip to main content

sampleReddit 🫴

A streamlined interface for generating snowball samples of Reddit data.

Snowball sampling is a data collection method that starts with a small set of seeds and iteratively collects data from their connections. This method is particularly useful for collecting data from social media platforms, where the connections between users and communities are often of primary interest. sampleReddit also outputs full documentation of each sampling process.

Installation

sampleReddit can be installed from PyPI using pip:

pip install sampleReddit

Quick Start

An annotated example of how to go from a list of seed subreddits to a snowball sample of Reddit comments can be found in this script.

Usage

The core functionality of sampleReddit resides in the sample_reddit function:

import sampleReddit as sr

sampling_frame, users_df = sr.sample_reddit(
    api_instance=instance,
    seed_subreddits=["politics", "news"],
    post_filter="top",
    time_period="year",
    n_posts="3",
    log_file_path="path/to/log/file.log",
)

The above function will conduct a snowball sample of Reddit users by collecting the top 3 posts from the "politics" and "news" subreddits from the past year and then the usernames of all the users who commented on those posts. The function returns two things:

  1. A Python dictionary object that documents the sampling frame. It maps subreddits to posts and posts to comments.
  2. A pandas DataFrame with a single column called "users" that lists the users who were sampled.

The library also provides lower-level functions that only sample posts from a subreddit, or comments from a list of posts IDs. For a full list of functions, see the documentation.

Note: Any access to the Reddit API requires an application that is registered with Reddit via their developer portal. Once your app is registered the setup_access function can be used to create an authenticated Reddit API instance. For instructions on how to set up a registered Reddit API application, refer to this guide.1

Testing is performed on Python 3.10, but everything should work on 3.6 or later.

Documentation

Full package documentation can be found in this repo's wiki.

Acknowledgments

sampleReddit is built on top of the PRAW (Python Reddit API Wrapper) library, which provides a comprehensive and flexible interface for the Reddit API.

  1. You will need a regular Reddit user account to complete the app authentication setup. ↩

Metadata

Release files for sampleReddit 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sampleReddit 0.1.5
File Size Uploaded
samplereddit-0.1.5.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sampleReddit 0.1.5
File Interpreter ABI Platform
samplereddit-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 18.0 kB

Release files / samplereddit-0.1.5.tar.gz

Download URL samplereddit-0.1.5.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7a2a7f39ad2d131f5e1451d7840db95799e7c4c6dc5976a76ee745197f94e645
BLAKE2b-256 checksum
How to use checksums
fc10ffbf8e7d7e21d7962cf633a466504daed6e373e19394694aea3c11fea8d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release files / samplereddit-0.1.5-py3-none-any.whl

Download URL samplereddit-0.1.5-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62379fd6c10b10e342e63fa1e68c2b3df59b77a786c2425b009061d87a4704a8
BLAKE2b-256 checksum
How to use checksums
349681f5c995c80e3a449726f47cae06cd18b4acfef5d7ddab2c62622bd4bc7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page