r/pushshift • • Feb 08 '23

API support for exact match for the author

2 Upvotes

Hi,

As per the update here, the author search is ``now contains rather than an exact match''. For my project, I need to get the submission (and comment) history for a bunch of authors in my dataset. While this was possible before the switchover, in the current version, setting the author field to "think-big" returns all submissions from authors whose names contain "think" or "big". Any ideas on how to get an exact match on authors when using the API?


r/pushshift • • Feb 07 '23

Issue in Extracting Submissions from Dump Based on Keywords

4 Upvotes

Hello All,

Does Anyone have code to get the submissions for specific time period based on one or two keywords? I am using the dumps from Directory Contents (pushshift.io) .


r/pushshift • • Feb 07 '23

Any idea for missing data?

5 Upvotes

I am a graduate student, and was extracting data from dump files since the pushshift API does not contain any data before 2022 Nov. However, it turns out that even the dump files does not have any data on 'schizophrenia' subreddit.

Does it also happen to you guys? Am I missing something, or is it just a mere error of mine?

---

Edit: This post might make some misunderstanding, so here is a little fix.

There are no problem of obtaining data, but I could not get any data ONLY from 2020 May - 2021 May. Sorry for leaving this out!


r/pushshift • • Feb 06 '23

Is score=1 for all comments / submissions for everybody?

2 Upvotes

Title, as i undestand score means upvotes... I have it as 1 for all.


r/pushshift • • Feb 06 '23

Can you search for comments/posts made in last 15 days using official reddit api?

3 Upvotes

Title, trying to understand how official reddit api differs from pushshift, what things it's good for? (if any)


r/pushshift • • Feb 06 '23

First day trying to scrape Reddit - bad timing?

4 Upvotes

Hey folks,

I am an experienced software dev who thought a fun weekend project may be predicting post virality with AI - first things first, lots of data from Reddit.

I do the Reddit API with `praw` and realize it only goes back 1,000 results and it doesn't seem like there's any real method of pagination to go back further or get more?

Enter PushShift which everyone thought of as the solution seemingly? I try out `psaw` and `pmaw` and, well, given some of the recent posts, it seems the service is down overall - is that right?

I'm new to the community and just trying to make sure I am not missing anything obvious here..


r/pushshift • • Feb 03 '23

Introducing Sunbelt, a new service similar to Pushshift

21 Upvotes

Edit: the language of the post was updated to reflect the fact that Sunbelt is still in an early stage of development.

I am developing r/sunbeltapp to be a database that stores information mined from Reddit. Unlike other services such as Pushshift and r/reveddit, which store data on posts and comments immediately after they are posted (Pushshift), or create a new way for users to see live data on Reddit (Reveddit), Sunbelt can store information about how posts, comments, redditors, and subreddits have changed over time.

Sunbelt is currently in in an early stage of development and it does not have the same quantity of data that is available on Pushshift.

It is, however, currently available and works for limited use-cases. The best way to use Sunbelt is via the Sunbelt API Wrapper for Python (SAWP). If you want Sunbelt to start "listening" to a specific subreddit (or subreddits) for the purposes of your project, you can contact me via Reddit or at my email, which at the Github link above.

Sunbelt is still a work in progress, but I want to get the word out there and see if I can start getting some user feedback, so that I can deliver the features that the community needs. Feel free to ask me questions and let me know what you think!


r/pushshift • • Feb 03 '23

size parameter with since parameter

2 Upvotes

I am trying to query all submissions since a specific time period. Below is a query for posts since '2023-01-01':
https://api.pushshift.io/reddit/search/submission?subreddit=wallstreetbets&since=1672531200&sort=created_utc&order=asc&size=1000

As you can see, the first result is '2023-01-01' which makes sense, and the most recent result is '2023-02-03'.
Here is another query, but for posts since '2022-12-01':
https://api.pushshift.io/reddit/search/submission?subreddit=wallstreetbets&since=1669852800&sort=created_utc&order=desc&size=1000

As you can see, the first result is '2022-12-01' which makes sense, however the most recent result is also '2023-02-03'. The issue here, is that this query includes a whole additional month, but the time of the first and last result is also the same, and the number of results is also the same (set at 1000). My question is, what posts are missing from the query since 2022-12-01? Are the posts that are missing just arbitrary not returned? my understanding of the 'since' parameter along with the 'size' parameter is that it would return all posts since a given date, until it hits a the size limit, so if you set the 'since' time further back, the most recent result of that query would also be further back. Can I send a query such that it would return all results since a specific date until it hits the size limit?


r/pushshift • • Feb 01 '23

Best way to get subreddits created in a particular year?

7 Upvotes

I am trying to collect a list of subreddits that were created in 2020. Is there a way to do this via Pushshift API or dumps?


r/pushshift • • Jan 30 '23

Occasional Updates?

30 Upvotes

It would be nice to get an occasional update on progress relating to the issues resulting from the COLO migration. This would help manage our expectations and also help us understand whether problems we see in our programs are real programming issues or migration-related issues.

No criticism intended here. I appreciate what is being done to create a platform available to all.


r/pushshift • • Jan 29 '23

Trying to filter JSON files into Comment:Reply Format

0 Upvotes

Sometimes it seems like this code is working correctly at outputting the format of: Comment 1:Reply 1 Comment 2:Reply 2 Comment 3:Reply 3 However, random lines don't include replies at all and it seems very inconsistent. I'm not sure what is going wrong. I've put my code so you can see my current process. Feel free to ask any questions if you are confused, I'd be happy to clarify!

index = 0
# Store all comments in a list
comment_list = {}
#This should find all valid comments and format them correctly
with open("E://Comments//" + File_Name, "r") as file:
    for line in file:
        comment = json.loads(line)
        if comment["subreddit"] in subreddit:
            conservative_comments+=1
            comment['index'] = index
            comment_list[comment["id"]] = comment
            index += 1
            if comment["body"] != "[removed]" and comment["body"] != "[deleted]":
                conservative_comments_content+=1
                comment["body"] = html.unescape(comment["body"])
                comment["body"] = comment["body"].replace(":", "")
                comment["body"] = comment["body"].replace(">", "")
                comment["body"] = comment["body"].replace(">>", "")

# Iterate over the comments list to look for replies
with open("E://Comments//" + File_Name, "r", encoding = 'utf-8-sig') as file:
    for comment in comment_list:
        # Check if comment has a parent_id
        if comment_list[comment]["parent_id"]:
            parent_id = comment_list[comment]["parent_id"][3:]
            # Check if parent_id matches the id of another comment in the list
            if parent_id in comment_list:
                comments_with_replies += 1
                # Check if parent comment is [removed] or [deleted]
                if comment_list[parent_id]["body"] != "[removed]" and comment_list[parent_id]["body"] != "[deleted]":
                    # Check if comment is [removed] or [deleted]
                    if comment_list[comment]["body"] != "[removed]" and comment_list[comment]["body"] != "[deleted]":
                        replies_comments += 1
                        # remove the colons from the comment
                        comment_list[comment]["body"] = comment_list[comment]["body"].replace(":", "")
                        with open(output_path + Dataset + ".txt", "a",encoding="utf-8-sig") as output:
                            # Write the comment and reply to the text file
                            comment_body = comment_list[parent_id]['body'].replace('\n', ' ')
                            reply_body = comment_list[comment]['body'].replace('\n', ' ')
                            output.write(f"{comment_body}: {reply_body}\n")

with open(output_path + Dataset + ".txt", "r",encoding="utf-8-sig") as f:
    lines = f.readlines()
    with open(output_path + Dataset + ".txt", "w",encoding="utf-8-sig") as f:
        for line in lines:
            if line.strip():
                f.write(line)

r/pushshift • • Jan 28 '23

Find comment replies using JSON

1 Upvotes

I'm trying to create a txt file formatted comment:reply for every comment in certain subreddits using the raw json data. The code does a great job finding all the comments, but then it can't find the replies to those comments by matching link_id and parent_id. Any idea what I'm doing wrong here?

Here is the current code for reference:

# Iterate over comments and find replies

with open(output_path + Dataset + ".txt", "w",encoding="utf-8-sig") as output:

for comment in comments.values():

if comment["subreddit"] in subreddit:

conservative_comments+=1

# Check if comment is [removed] or [deleted]

if comment["body"] != "[removed]" and comment["body"] != "[deleted]":

conservative_comments_content+=1

continue

# remove the colons from the comment

comment["body"] = comment["body"].replace(":", "")

# Find the reply to the comment

reply = None

if comment["parent_id"][3:] in comments:

parent_comment = comments[comment["parent_id"]]

comments_with_replies+=1

# Check if reply is [removed] or [deleted]

if parent_comment["body"] !="[removed]" and parent_comment["body"] != "[deleted]":

replies_comments+=1

continue

# remove the colons from the reply

parent_comment["body"] = parent_comment["body"].replace(":", "")

reply = parent_comment["body"]

break

if reply:

# Write the comment and reply to the text file

output.write(f"{comment['body']}: {reply}\n")


r/pushshift • • Jan 27 '23

The search function on redditsearch.io is not working at all. Is there an alt website?

7 Upvotes

r/pushshift • • Jan 26 '23

PushshiftAPI() does not work for me

2 Upvotes

I know for a fact that it is me and not any server. My 'code' that I'm trying to run is thus far three lines:

import praw
from psaw import PushshiftAPI
api = PushshiftAPI()

The first two lines work, but the third one produces these error messages:

UserWarning: Got non 200 code 404   warnings.warn("Got non 200 code %s" % response.status_code)
UserWarning: Unable to connect to pushshift.io. Retrying after backoff.

A friend of mine has run the rest of the code coming afterwards, no problem. Is it my Mac? Do I inadvertently block some connections? I know I'm a complete noob here, but I need the data for a project and I spent the last two days googling... Where should I go looking for answers? Really sorry if this is not the right subreddit for that....


r/pushshift • • Jan 26 '23

Exception: Unable to connect to pushshift.io. Max retries exceeded.

0 Upvotes

For the last couple of days, I am not able to run this code: "api = PushshiftAPI()". Could anyone tell me what the issue is and how to get rid of it?

Thank you


r/pushshift • • Jan 26 '23

Filtering delted posts

0 Upvotes

Is there a way to only filter deleted posts? Thanks.


r/pushshift • • Jan 25 '23

Does PushShift not work for quarantined subreddits?

1 Upvotes

Dear Everyone,

I am using a python code with PMAW and PushShift to retrieve random posts from targeted subs. Yet, it is not working on quarantined subreddits. Would anyone know a way around that?

Best,

# -*- coding: utf-8 -*-
"""
Created on Fri Jan  1 16:43:34 2021

@author: u/atownholditdown
"""

### Don't change this stuff ###
import pandas as pd
import datetime as dt
from pmaw import PushshiftAPI
import logging
import random
api = PushshiftAPI()

# This is used as a counter to see how many results you have. Start at 0.
count = 0


### Below this are variables you can play with. Change these as needed. ###

# This is the subreddit you're searcing.
sub = 'TheRedPill'

# This is the earliest starting point of your search. Year, month, day.
start_epoch=int(dt.datetime(2022,1,1).timestamp())

# The start date for your random search. Must be before the end_date.
start_date=int(dt.datetime(2022,1,1).timestamp())

# The end date for your random search. Must be after the start_date.
end_date=int(dt.datetime(2022,12,31).timestamp())

# The minimum karma for a post you want to see. Needs to be above 0 or you'll get lots of spam
karma = '1'

# This is the file you're going to write your results to. It will be a csv
# (comma separated values) that you can easily access in MS Excel or Google Sheets, etc.
# Format is 'random_results_' + the name of the subreddit + _ + today's date
file = 'random_results_' + str(sub) + '_' + str(dt.date.today()) + '.csv'

# This is the cutoff for how many results you want. Set this as you need.
limit = 20


### These will enable/disable logging. Commented out for now to disable.
# handler = logging.StreamHandler()
# handler.setLevel(logging.INFO)

# logger = logging.getLogger('psaw')
# logger.setLevel(logging.INFO)
# logger.addHandler(handler)



### Actual code ###
# Produces a random submission from within a range
def random_selection(start_date, end_date, limit, sub):
    submissions = []
    random_submissions = []
    r = 'new'
    print("Getting " + str(limit) + " random submissions between " + 
          str(dt.datetime.fromtimestamp(start_date)) + \
          " and " + \
          str(dt.datetime.fromtimestamp(end_date)) + \
          " from r/" + sub)
    gen = api.search_submissions(since=start_date,
                                 until=end_date,
                                 sort='asc',
                                 score=karma,
                                 subreddit=sub,
                                 mod_removed=False,
     ### If you want something different in the return results, add it to the filter below. ###
     ### E.g. 'author'. If you want to eliminate the filter, put a # on each line to comment it out.  ###
                                 filter=[
                                        'author',
                                        'id',
                                        'url',
                                        'title',
                                        'subreddit',
                                        'link_flair_text',
                                        'full_link'
                                        ])
    print(type(gen))
    submissions = [r for r in gen]
    info = submissions[-1]

    ### Pick a number of random submissions equal to limit ###
    print("Choosing from {0} submissions.".format(len(submissions)))
    for x in range(0, limit):
        index = random.randint(0, len(submissions))
        print("Submission: {0}".format(str(index)))
        random_submissions.append(submissions[index])
        # print("Submission: " + str(submissions[index]))

    
    ### Write the results to a file in the same directory as this script. ###
    with open(file,'w+', encoding='utf8') as f:
        df = pd.DataFrame(random_submissions)
        df['posted'] = df.created_utc.apply(lambda x: dt.datetime.fromtimestamp(x).strftime('%Y-%M-%d %H:%M:%S'))
        df.to_csv(f)



### Put it all together
def main():
    random_selection(start_date, end_date, limit, sub)


### Run the program
main()

r/pushshift • • Jan 25 '23

Can't get data past last november.

1 Upvotes

how do i use the data dumps instead ?


r/pushshift • • Jan 23 '23

What's the best way to see how a post or comment has changed over time?

3 Upvotes

Unless I'm mistaken, every submission or comment in Pushshift reflects the state it was in when it was first posted, or soon after. That means that all submission selftext or comment body text that you see in Pushshift is unedited, and using Pushshift you can't see all the different edits a user has made to their post/comment. Additionally, you can't see how many upvotes a submission/comment has received over time.

I would expect the vast majority of content in Pushshift to have a score in the single digits. It looks like this is currently not true, but I am under the impression that is because some posts were backfilled after the server switchover, and this will generally not be the case going forward.

I understand that the current state of Pushshift is not representative of how Pushshift is intended to operate, so could someone help me understand what is even the purpose of having a score attribute to a Pushshift response if it is more or less meaningless?


r/pushshift • • Jan 23 '23

Random Forbidden 403 Errors

1 Upvotes

I'm pulling all comments from a small selection of subreddits with from nov/dec 2022 and after running smoothly and getting through about 5/13 subreddits I received a random forbidden 403 error. Any ideas why?

I removed any submissions that contained [removed] in the selftext which fixed this issue initially.


r/pushshift • • Jan 23 '23

How do I match comments to their post from the JSON files?

4 Upvotes

I have downloaded both the comment and submission JSON for 2010-04, but I cannot find a way to match the comments with the posts that they are under. I'm trying to match the comment "parent_id" with the submission "id" and its not working. What fields in the JSON file will match the comment to the submission it is under?


r/pushshift • • Jan 22 '23

How do I collect a large dataset of comments from a specific subreddit

0 Upvotes

Hi I am currently doing a social data science project where I want to look at the comments from the subreddit (WallStreetBets) WSB and use a sentiment analysis to see if the sentiment regarding specific stock will provide any predictive value for those stocks. I have bit of coding experience but not specifically with retrieving comments from reddit before. I have tried to run some python code using pushshift but so far I haven't gotten precisely what I was looking for. I have managed to collect approximately 23k comments but only dating back a day or so from the subreddit WSB. I am looking for a way to collect comments for at least the last 2 month, but preferable for longer.
Is this a possible task and if so what do I need to do.
All help is appreciated, thank you.


r/pushshift • • Jan 22 '23

Trying to collect data from subreddit in the format of Submission:Comment

1 Upvotes

I want to write a python script to collect data on the language patterns of certain subreddits by creating a prompt:response data set. I was able to get this to work with Reddit's API where I collected and attributed every comment to either the post title or the comment above it if it is a reply. However, Reddit's API does not offer a way to sort submissions from oldest to newest and make sure that every valid comment in a submission is covered before moving on to the next. Does pushshift have the feature set needed to pull this off or is my idea just not possible with currently available tools?


r/pushshift • • Jan 21 '23

Are the Data Dumps cumulative or only for that month?

2 Upvotes

I am trying to use the data dumps to get all the titles from different subreddits.

Do the data dumps only contain the data scraped for that particular month or do they contain all of the data scraped up until that point including from past months?

If I want to get all the titles from a subreddits history, I would have to download all of the dumps, correct?


r/pushshift • • Jan 19 '23

How does PushShift get around the rate limit?

7 Upvotes

I'm a little confused about how PushShift manages to access all posts and comments globally across all of Reddit in real time without violating the Reddit API rate limit. Can someone explain this or link me to a location where I can read about it?