mattpodolak / pmaw

A multithread Pushshift.io API Wrapper for reddit.com comment and submission searches.
MIT License
212 stars 28 forks source link

Why can't I query all comments in the last 7 days? #21

Closed SayonB closed 3 years ago

SayonB commented 3 years ago

Why does this return 0 result(s) available in Pushshift

from pmaw import PushshiftAPI
from datetime import datetime, timedelta

api = PushshiftAPI()
seven_days_ago = (datetime.now() - timedelta(days=7)).timestamp()
comments = api.search_comments(after=seven_days_ago)

>>> 0 result(s) available in Pushshift

while if I directly query pushshift using the same parameters, I get results.

>>> seven_days_ago
>>> 1624497069.970137

https://api.pushshift.io/reddit/comment/search?after=1624497069

In addition: apparently, an integer value is needed, but only works if a subreddit or query term is given

>>> comments = api.search_comments(subreddit="science", after=seven_days_ago)
0 result(s) available in Pushshift
>>> comments = api.search_comments(subreddit="science", after=int(seven_days_ago))
15132 result(s) available in Pushshift
>>> comments = api.search_comments(q="science", after=int(seven_days_ago))
36019 result(s) available in Pushshift
mattpodolak commented 3 years ago

Hi @SayonB , yes an integer value is required for the before and after parameters.

but only works if a subreddit or query term is given

I'm not sure what you mean. Can you provide an example query with what you expected to happen and what actually happened?