Rishikant181 / Rettiwt-API

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

User Timeline - Limit to specific date ranges #408

Closed flawnn closed 5 months ago

flawnn commented 6 months ago

Hi!

Is the following as in the title possible, to get tweets from a timeline of a user between a specific range of date? I tried doing that over searching in combination with the fromUsers search parameter, but it doesn't work as I don't get any results (because I probably don't search for any words (as I want to fetch all tweets from that user and not filter by content))

Any idea/plans to implement that? Or suggestions how to get working what I try?

Cheers!

Rishikant181 commented 6 months ago

Unfortunately, such filters can only be used while using the 'search' function (which requires logging in). In order to search in specific date range, use the following filter:

import { Rettiwt } from 'rettiwt-api';

// Creating Rettiwt instance using API_KEY
const rettiwt = new Rettiwt({ apiKey: API_KEY });

// Searching for tweets from the user 'user1' in the date range 2023-01-01 -> 2023-01-31
// The dates are in the format YYYY-MM-DD
// Instead of this format, any standard date string can be used
rettiwt.tweet.search({
    fromUsers: ['user1'],
    startDate: new Date('2023-01-01'),
    endDate: new Date('2023-01-31')
})
.then(res => {
    // Do something
})
.catch(err => {
    // Do something
});

Further, due to recent changes in Twitter, when not logged in, the 'timeline' function returns the top posts of the user and recent posts are only returned when logged in.