Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
303 stars 31 forks source link

Can't exclude replies in search. (`replies: false` ignored?) #556

Closed dschwertfeger closed 4 days ago

dschwertfeger commented 1 week ago

v3.0.2

rettiwt.tweet
  .search({
    fromUsers: [<username>],
    replies: false,
  })
  .then((data) => {
    ...
  })
  .catch((err) => {
    ...
  });

data still contains replies.

How can I exclude replies from search?

Rishikant181 commented 1 week ago

Oops, it's an error on my part (sorry :P). Earlier, the replies: false used to work (that was a long time ago). At some point, twitter made it such that replies are always returned, and the only thing you can do is exclude original tweets from the results, but the replies will be returned regardless. I failed to reflect those changes in the documentation as well as parameter naming :P

Still, I'll be cross checking it in the morning.

dschwertfeger commented 1 week ago

Appreciate your quick reply!

Curious… Are you saying 𝕏's API doesn't offer to exclude replies at all?

I've been using the on-site search with puppeteer and it allows you to exclude:replies. So a query like from:<username> exclude:replies since:2024-06-01 turns into:

https://x.com/search?q=from%3A<username>%20exclude%3Areplies%20since%3A2024-06-01&src=typed_query&f=live

Decoded:

https://x.com/search?q=from:<username> exclude:replies since:2024-06-01&src=typed_query&f=live

…and doesn't return replies.

I didn't yet fully drill down into how you construct the requests. But do you think it might be possible to exclude replies using the exclude parameter?

Rishikant181 commented 1 week ago

Thanks for the info. I didn't know about the exclude parameter while reverse engineering the Twitter Web App, I'll check it now and if it works, I'll create a patch.

Rishikant181 commented 1 week ago

Okay so the already implemented could should have worked. I say "should have" because I'm dumb and my code doesn't include the -filter:replies in the final query string.

Fixing it now. Expect patch soon.

Rishikant181 commented 1 week ago

This has been fixed in v3.0.3. Please update to see changes and let me know if it works as expected.

dschwertfeger commented 1 week ago

Fantastic! Works now.

Thanks for the quick fix! Glad it was a rather simple one. :)