skip to Main Content

I’m trying to retrieve tweets containing a specific hashtag using the twit library in JavaScript. However, I’m encountering an error related to limited access to certain Twitter API endpoints. The error message I’m receiving is:
You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g., media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product

Here’s the code I’m using:

const Twit = require('twit');

const XLSX = require('xlsx');

// Twitter API credentials (replace with your own)

const T = new Twit({

  consumer_key: 'YOUR_CONSUMER_KEY',

  consumer_secret: 'YOUR_CONSUMER_SECRET',

  access_token: 'YOUR_ACCESS_TOKEN',

  access_token_secret: 'YOUR_ACCESS_TOKEN_SECRET'

});

// Search parameters

const hashtag = '#Example';

const count = 100; // Number of tweets to retrieve

// Search tweets containing the hashtag

T.get('search/tweets', { q: hashtag, count }, (err, data) => {

  if (err) {

    console.error('Error:', err);

    return;

  }

  

  const tweetLinks = data.statuses.map(tweet => `https://twitter.com/${tweet.user.screen_name}/status/${tweet.id_str}`);

  

  // Create a new worksheet

  const ws = XLSX.utils.aoa_to_sheet([tweetLinks]);

  const wb = XLSX.utils.book_new();

  XLSX.utils.book_append_sheet(wb, ws, 'Tweet Links');

  

  // Save the Excel file

  XLSX.writeFile(wb, 'tweetLinks.xlsx');

  

  console.log('Excel file generated with tweet links.');

});


I believe the error is related to the endpoint I’m trying to access. How can I resolve this issue and gain access to the necessary Twitter API endpoint to retrieve the tweets I need? Any guidance or suggestions would be greatly appreciated.

Additional Information:

I’m using the twit library in Node.js to interact with the Twitter API.

I have checked my Twitter API credentials, and they seem to be correct.

I’m specifically trying to retrieve tweets with a certain hashtag: #Example.

By providing a clear title and a detailed explanation of your issue along with the code you’re using, you’re more likely to receive accurate and helpful responses from the Stack Overflow community.

I am confused what to do at this point and i am expecting a solution for my error

2

Answers


  1. Please follow up with Twitter API documentation here enter link description here

    v1.1 has been deprecated (removed), and if there is no alternative API available in v2, you can’t really access it without Enterprise API access.

    Btw, the Enterprise API access is 42000 USD per month, no consumption based model.

    Login or Signup to reply.
  2. I’m also Getting the same Problem of

    {"message":"You currently have access to a subset of Twitter API v2 endpoints and limited v1.1 endpoints (e.g. media post, oauth) only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/portal/product","code":453}
    

    And After Reading the Twitter (X) Documentation the only answer is to use the BASIC and PRO Level Access to get the data of tweets.

    There is no other way!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search