Rishikant181 / Rettiwt-API

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

How do I know the type of tweet #539

Closed spencer17x closed 6 months ago

Rishikant181 commented 6 months ago

I'm afraid I'll need a bit more explanation.

spencer17x commented 6 months ago

For example, the type of tweet has retweets, comments, etc., which field indicates that the tweet message belongs to that type

Rishikant181 commented 6 months ago

Unfortunately, Twitter does not make any distinction regarding the type of tweet. All comments, retweets, etc are all treated as tweets. To check what "type" of tweet it is, you have to manually inspect the fields of the tweet.

For example, if a tweet is a reply, it's replyTo field will be non-null. Similarly, if a tweet is a quoted field will be non-null and so on.

spencer17x commented 6 months ago

Why can't tweet.search get retweets

Rishikant181 commented 6 months ago

That's how the search endpoint works on Twitter, unfortunately.

Ig twitter treats retweets as non-original tweet, since all the user did was share someone else's tweet. Quotes and replies on the other hand, however, also include additional input from the user, so they are considered as "original" tweets. That's just how Twitter works.

spencer17x commented 6 months ago

Which api should I call if I want to specify some user's retweets, likes, etc

Rishikant181 commented 6 months ago

For the likes, you can user the user.likes method.

As for the retweets, although no direct method exists, but you can fetch the timeline of the user which contains the original tweets as well as retweets using the method user.timeline. Then filtering out the original tweets by checking the id of the user who made the tweet will leave you with all the retweets.

Remember, this library is made by reverse engineering the API endpoints used by the Twitter Web App. So this library can only achieve what the Web App can do and nothing more.

spencer17x commented 6 months ago

For the likes, you can user the user.likes method.

As for the retweets, although no direct method exists, but you can fetch the timeline of the user which contains the original tweets as well as retweets using the method user.timeline. Then filtering out the original tweets by checking the id of the user who made the tweet will leave you with all the retweets.

Remember, this library is made by reverse engineering the API endpoints used by the Twitter Web App. So this library can only achieve what the Web App can do and nothing more.

If I have multiple users, it's not one request per user

Rishikant181 commented 6 months ago

For multiple users, you'll have to make individual requests.