1

Trying to use the user mention timeline via twitter-api-v2 and it always says there are no tweets mentioning the user, I've tested out many different user id's and they all give the same result.

_realData: { meta: { result_count: 0 } }

const getMentions = async () => {
    try {
       const mentions = await rwClient.v2.userMentionTimeline('141664648', { end_time: '2011-11-06T00:00:00-00:00' });
        console.log(mentions);
    } catch (e) {
        console.error(e);
    }
}

getMentions();

outputs

TweetUserMentionTimelineV2Paginator {
  _maxResultsWhenFetchLast: 100,
  _realData: { meta: { result_count: 0 } },
  _rateLimit: { limit: 450, remaining: 449, reset: 1673495653 },
  _instance: TwitterApiv2 {
    _currentUser: null,
    _currentUserV2: null,
    _requestMaker: ClientRequestMaker {
      rateLimits: [Object],
      clientSettings: {},
      bearerToken: '<my bearer token>'
    },
    _prefix: 'https://api.twitter.com/2/'
  },
  _queryParams: { end_time: '2011-11-06T00:00:00-00:00' },
  _sharedParams: { id: '141664648' },
  _endpoint: 'users/:id/mentions'
}

1 Answers1

0

It works fine for userMentionTimeline() in 'twitter-api-v2' It just hard to find a good time slot for user.

Demo Code

import { TwitterApi } from 'twitter-api-v2';

const getMentions = async () => {
    try {
        const twitterClient = new TwitterApi('**************************************');
        const readOnlyClient = twitterClient.readOnly;
        const mentions = await readOnlyClient.v2.userMentionTimeline('415859364', { start_time: '2023-01-12T05:12:01Z', end_time: '2023-01-12T05:20:01Z' });
        return Promise.resolve(mentions.data);
    } catch (error) {
        return Promise.reject(error);
    }
}

getMentions()
    .then((result) => {
        console.log(JSON.stringify(result, null, 4))
    })
    .catch(error => {
        console.error(error);
    });

Result from terminal

enter image description here

Confirmed by v2 API call by Postman.

enter image description here

Check the two tweet's time stamp. - It agree with API results.

The API and display time are different due to UTC (API time) and UTC+8 (tweet UI time) difference display but it is same if convert UTC+8 (display) to UTC (API).

https://twitter.com/cielbleu011/status/1613405379060457472

enter image description here

https://twitter.com/cielbleu011/status/1613405151326527489

enter image description here

Bench Vue
  • 5,257
  • 2
  • 10
  • 14