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

Cant get last tweet sometimes #526

Closed Nevgup closed 1 month ago

Nevgup commented 2 months ago

Hello

Sometimes, I don't know why, i can't get the last tweet, there is no list[] key in the CursoredData For example I have this code :

    public async getLastTweetFromUser(fromUser: string[], words?: string[]): Promise<Tweet|any> {
        try {
            const searchParams: { fromUsers: string[]; words?: string[] } = { fromUsers: fromUser };

            if (words) {
                searchParams.words = words;
            }

            const response = await this.client.tweet.search(searchParams, 1);

            console.log(response)
            return response.list[0];
        } catch (error) {
            console.log(error)
        }
    }

If i use it on a certain user, I'll have something like this for response

CursoredData {
  list: [],
  next: Cursor {
    value: 'cursoredvaluehere'
  }
}

I don't know why the list is empty, since there is a real tweet that I can see on Twitter

Thanks for your help

Rishikant181 commented 2 months ago

Any specific user which triggers this bug? That way, I'll be able to reproduce the issue.

Nevgup commented 2 months ago

Ok now i don't have this problem anymore idk why But, do you know why the created timestamp of the tweet is for example at 13:15:17.878Z and I check a user.timeline(id) at 13:15:18.215, but it wont returns the new tweet

How can I do for this please ?

BojanPanic commented 1 month ago

I just encountered this bug as well. It takes a full minute before new tweet can be seen in response.

const getTweet = async () => {
  const res = await rettiwt.tweet.search(
    { fromUsers: ["test1"], replies: false },
    1
  );
  console.log(res);
};

Steps to reproduce.

  1. Post a new tweet on any account
  2. Immediately run the code above to fetch tweet
  3. For a full minute after posting new tweet the response will look like this
CursoredData {
  list: [],
  next: Cursor {
    value: 'cursoredvaluehere'
  }
}

Only after a minute the response has Tweet object inside the list

Rishikant181 commented 1 month ago

Checking on it now

Rishikant181 commented 1 month ago

Okay so turns out, this is how just Twitter works. The endpoint used to scrape tweets is the same which used to search tweets. And that endpoint, shows results just after a delay (maybe because it does some indexing in the background).