node-red-nodes icon indicating copy to clipboard operation
node-red-nodes copied to clipboard

Twitter v2.0 API not supported (returns 403)

Open joepavitt opened this issue 2 years ago • 26 comments

Which node are you reporting an issue on?

Twitter

What are the steps to reproduce?

  1. Create a new instance of Node-RED
  2. Add the Twitter node
  3. Add an App/Project through the Twitter Developer Portal

What happens?

  • Receive a "stream error: http (403)" error from the Twitter API

This is because Twitter have restricted access for "Essential" developer accounts (the default account provided when signing up for a Twitter developer account) to using the v2 API only. In order to use the v1.1 API, developers must have an "Elevated" account.

What do you expect to happen?

  • Should be able to utilise the Twitter nodes, without the requirement to upgrade to an "Elevated" Twitter dev account.

joepavitt avatar Apr 08 '22 17:04 joepavitt

There is an updated Twitter NodeJS SDK: https://www.npmjs.com/package/twitter-api-v2

@Steve-Mcl and I have tested that this works in Node-RED by installing it as an npm package and used the following example, to listen for any tweet mentioning 'Boris Johnson' in a function node:

const { TwitterApi, ETwitterStreamEvent } = twitterApiV2;

// Instanciate with desired auth type (here's Bearer v2 auth)
const twitterClient = new TwitterApi("<Bearer_Token>");

// Tell typescript it's a readonly app
const roClient = twitterClient.readOnly;

const addedRules = await roClient.v2.updateStreamRules({
    add: [
        { value: 'Boris Johnson' },
    ],
});

// const stream = roClient.v2.sampleStream({ autoConnect: true });
const stream = await roClient.v2.searchStream();

stream.on(ETwitterStreamEvent.Connected, function () {
    node.send({
        payload: "Connected"
    });
});
stream.on(ETwitterStreamEvent.ConnectError, function() {
    node.send({
        payload: "Conect Error"
    });
});
stream.on(ETwitterStreamEvent.ConnectionError, function () {
    node.send({
        payload: "Conection Error"
    });
});
stream.on(ETwitterStreamEvent.Error, function () {
    node.send({
        payload: "Error"
    });
});
stream.on(ETwitterStreamEvent.Data, function () {
    node.send({
        payload: [...arguments]
    });
});

joepavitt avatar Apr 08 '22 17:04 joepavitt

This problem also happens even with elevated status. Twitter Out works fine, but Twitter In still gets the 403 on public searches. Tweets from followed accounts works as expected..

boomvalt avatar May 20 '22 12:05 boomvalt

I have developed a node-red-twitter-node that gets the public searches. You can find the code here: https://github.com/shahramdj/nodered_twitter_api I also made a youtube video that shows how you can use the new node: https://www.youtube.com/watch?v=HYn3sIDcIv4&t=78s

shahramdj avatar Oct 06 '22 18:10 shahramdj

@shahramdj rather than adding another node to the catalogue could we persuade you to raise a pull request to fix the existing node. This way there is just one that works and people don't have to pick from multiple options and it's the one from the community that people are likely to already have installed. Thanks

hardillb avatar Oct 06 '22 20:10 hardillb

@hardillb sure, I will send a pull request to fix the existing node.

shahramdj avatar Oct 07 '22 02:10 shahramdj

Existing twitter node must be migrated from twitter-ng to twitter-api-v2(https://www.npmjs.com/package/twitter-api-v2)

akashtalole avatar Nov 19 '22 11:11 akashtalole

... or wait a couple of months and see what happens :-)

dceejay avatar Nov 20 '22 10:11 dceejay

... or wait a couple of months and see what happens :-)

Are we to take this to mean the devs are not supporting this node anymore?

gemini86 avatar Dec 05 '22 16:12 gemini86

Hi @gemini86

I think the comment from @dceejay was more related to the ongoing turmoil with Twitter the company and doubts over whether the company was going to have anyone left to keep it running.

More generally, there are dozens of nodes in this repository. Ideally we'd have the resources available to fix everything and implement everything - but unfortunately we don't. The degree to which any particular node gets maintained depends a lot on how widely used it is, how much community interest there is in it and whether people want to contribute to the project to help maintain them.

knolleary avatar Dec 05 '22 16:12 knolleary

I'm aware, which is why I asked without getting into the politics of it. I guess we wait?

gemini86 avatar Dec 05 '22 16:12 gemini86

... or help @shahramdj fix/rewrite it :-)

dceejay avatar Dec 05 '22 17:12 dceejay

Announcing the deprecation of v1.1 statuses/filter endpoint

I guess that means the node will stop working on 9 March 2023?

ohrenweide avatar Feb 13 '23 15:02 ohrenweide

See https://github.com/node-red/node-red-nodes/issues/1000 I am unable to tweet from Node-red

ArfyFR avatar May 27 '23 08:05 ArfyFR

Thank you [ArfyFR] for pointing this out. For me personally, however, the abolition of free unlimited API access has settled the matter. I will not pay money for the opportunity to add value to the platform through useful bots.

ohrenweide avatar May 27 '23 09:05 ohrenweide

Thank you [ArfyFR] for pointing this out. For me personally, however, the abolition of free unlimited API access has settled the matter. I will not pay money for the opportunity to add value to the platform through useful bots.

If I understand right: Unlimited: yep no more, but Tweet caps - Post 1,500 (I suppose per month) v1.1 is for media only now V2 we should still able to send tweets

But in node-red code both try to add media and text with V1.1 => fail

ArfyFR avatar May 27 '23 10:05 ArfyFR

Unlimited: yep no more, but Tweet caps - Post 1,500 (I suppose per month)

I have been running #NowPlaying bots for BBC Radio 1/ 2/3 and BBC6Music. The limit of 1500 tweets per month is already exceeded after a few days in this case 🤷

ohrenweide avatar May 27 '23 11:05 ohrenweide

I post less then few tweets per day and I find this plugin very useful. Is anyone working on this?

8666 avatar Aug 14 '23 22:08 8666

I post less then few tweets per day and I find this plugin very useful. Is anyone working on this?

no immediate plan that I'm aware of, with the Twitter API restrictions added, I think this dropped in priority as I understood that you needed to pay for API access now?

joepavitt avatar Aug 16 '23 12:08 joepavitt

Posting is free (with limits) but some endpoints are not available for free anymore

8666 avatar Sep 01 '23 13:09 8666

Anybody working on a fix? Would be nice to be able to use the node to send tweets.

@shahramdj any luck with the pull request?

jbwiden avatar Nov 09 '23 15:11 jbwiden

Nobody seems to have grabbed this yet unfortunately @jbwiden

joepavitt avatar Nov 14 '23 10:11 joepavitt

The twitter API has changed a lot, it is not free anymore and even my fix for API version 2 does not work now.

shahramdj avatar Nov 14 '23 15:11 shahramdj

My understanding is that there is still capability at the free tier but is more limited than in the past.

Free: Free, instant access to the X API. Includes 1,500 Posts /month and a single App environment. 1 App, 1 Project.

https://developer.twitter.com/en/support/twitter-api/v2

jbwiden avatar Nov 14 '23 16:11 jbwiden

I had a look again and even the basic API V2 example code does not work, I get 403 error when I try to call the rules URL. I tried to find new examples, code snippets, etc. but most of the links are broken. I am not sure, maybe the free version is not their priority and they are too busy with fixing the enterprise version. Unfortunately, there is no chance at this point to fix this. If you can find any working Nodejs code that gets the twitter stream, I will be more than happy to take it and fix the node-red node twitter based on that.

shahramdj avatar Nov 14 '23 20:11 shahramdj

Thanks for looking into it, sorry to hear it is seemingly a non operational API now

jbwiden avatar Jan 08 '24 04:01 jbwiden