Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

15
How to get an archive of ALL your comments from Reddit using the Pushshift API
Post Body

The following Python code will collect all comments for a user (set the author variable to your user name to get all of your comments) and print out JSON blobs which you can direct to a file. This will get all comments (even beyond the 1,000 available via your Reddit user-page)

#!/usr/bin/env python3

import requests
import time
import json

def get_comments_from_pushshift(**kwargs):
    r = requests.get("https://api.pushshift.io/reddit/comment/search/",params=kwargs)
    data = r.json()
    return data['data']

def get_comments_from_reddit_api(comment_ids,author):
    headers = {'User-agent':'Comment Collector for /u/{}'.format(author)}
    params = {}
    params['id'] = ','.join(["t1_"   id for id in comment_ids])
    r = requests.get("https://api.reddit.com/api/info",params=params,headers=headers)
    data = r.json()
    return data['data']['children']

before = None

### IMPORTANT ######################
# Set this variable to your username
author = "stuck_in_the_matrix"
####################################

while True:
    comments = get_comments_from_pushshift(author=author,size=100,before=before,sort='desc',sort_type='created_utc')
    if not comments: break

    # This will get the comment ids from Pushshift in batches of 100 -- Reddit's API only allows 100 at a time
    comment_ids = []
    for comment in comments:
        before = comment['created_utc'] # This will keep track of your position for the next call in the while loop
        comment_ids.append(comment['id'])

    # This will then pass the ids collected from Pushshift and query Reddit's API for the most up to date information
    comments = get_comments_from_reddit_api(comment_ids,author)
    for comment in comments:
        comment = comment['data']
        # Do stuff with the comments (this will print out a JSON blob for each comment)
        comment_json = json.dumps(comment,ensure_ascii=True,sort_keys=True)
        print(comment_json)

    time.sleep(2)

Author
Account Strength
100%
Account Age
11 years
Verified Email
No
Verified Flair
No
Total Karma
143,730
Link Karma
34,810
Comment Karma
108,242
Profile updated: 19 hours ago
Posts updated: 6 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
6 years ago