FeedHive/twitter-api-client

Add tweet_mode parameter

ChronSyn opened this issue ยท 9 comments

Is your feature request related to a problem? Please describe.
The statusesUserTimeline (and possibly other endpoints) supports a tweet_mode parameter. Such value can be extended which allows the full text content of the tweet, and it's hashtags, to be returned in the response.

Describe the solution you'd like
Update the typings to support the extended response structure, as well as adding tweet_mode to the supported args for tweets.statusesUserTimeline function.

Describe alternatives you've considered
For the moment, using //@ts-ignore prevents warnings about invalid parameters and response fields.

Additional context
Sample API response: https://gist.github.com/ChronSyn/f215c96aedfd56b2d7085f4b0f1f4b02

Hi @ChronSyn
Thank you for creating this issue.

Great, I'll make sure to look into this.
And thank you for providing the sample response ๐Ÿ™Œ

This task is up for grabs during Hacktoberfest ๐Ÿ™Œ

If you want to work on this task, please claim it here in the comments.
Feel free to ask any questions here as well ๐Ÿ˜Š

Hey i would like to give it a try! Can you give me more information about this issue? Thanks

tweet_mode seems to be an undocumented feature of twitter API.
The only place I could find a reference is another related repository:
tweepy/tweepy#1170

Correct me if I'm wrong @ChronSyn.
Also, could you share a snippet for a tweet where you can see the difference when tweet_mode is activated against where it's not?

@silind, Do you think it is a good idea to add this parameter to each endpoint at a time, Or do we want to think of a broader solution?

Found a reference to tweet_mode in twitter docs here:
https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/migrate/standard-to-twitter-api-v2

This parameter enables developers to request a series of different extended fields introduced in the years since statuses/show and statuses/lookup were introduced. It has been replaced with the fields and expansions functionality.

I could see that when using tweet_mode='extended' the field text was replaced with full_text in the response. While quering tweets.statusesUserTimeline

Sorry for the late reply!
Let's look into a more generic approach at a later point.
I think how you handled it in the PR is great for now.

Added in v. 1.0.3

Could you add full_text to the type definitions?

Could anyone also add the tweet_mode parameter to the method twitterClient.accountsAndUsers.listsStatuses ?

I tried forking the project and doing this myself, but I'm currently troubleshooting errors trying to get the "generate" and "build" commands to work (having made no changes to any code)... therefore, at least until I figure out these issues, I can't follow the proper contribution guidelines.

I believe all that's required is a copy and paste edit, adding the following (as used on other endpoints in accounts-and-users.yml) to the parameters of Get lists/statuses in this file https://github.com/FeedHive/twitter-api-client/blob/main/src/specs/v1/accounts-and-users.yml:

          - name: tweet_mode
            description: Valid request values are compat and extended, which give compatibility
              mode and extended mode, respectively for Tweets that contain over 140 characters
            required: false
            type: boolean

I've confirmed that this parameter works on this method, by ignoring typescript errors with tweet_mode: "extended" as a parameter on twitterClient.accountsAndUsers.listsStatuses()

I'll also continue troubleshooting the errors I had running the build and run commands (the commands don't work on Windows OS) and submit a PR if nobody is free to make these changes.