question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No media when retreiving a list of tweets

See original GitHub issue

I am trying to get a tweets from a list with its media but apparently, the media_field is not present and gives the error:

x = client.get_list_tweets(4343, expansions=["attachments.media_keys", "author_id"], 
                             tweet_fields = ['created_at', 'text', 'id', 'attachments', 'author_id', 'entities'], 
                           media_fields=['preview_image_url', 'url'])

and here is the error The query parameter [media_fields] is not one of [id,max_results,pagination_token,expansions,tweet.fields,media.fields,poll.fields,place.fields,user.fields]

Any help?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Harmon758commented, Aug 19, 2022

Thanks for the bug report. This should be fixed now.

This was due to the Twitter API documentation for the endpoint this method uses not listing media.fields, place.fields, or poll.fields as parameters, which got translated into Tweepy not supporting them as parameters.

Moreover, twitter API (https://developer.twitter.com/en/docs/twitter-api/lists/list-tweets/api-reference/get-lists-id-tweets) indicates that the media.fields argument is available.

@phisanti I don’t see that on that page, and place.fields and poll.fields are actually missing as well.

@spirale21 Client.get_list_tweets returns a Response object, which doesn’t have a media attribute.

If you look at the twitter api v2 documentation, the media url is retrieved by including expansions=attachments.media_keys&media.fields in the http request.

@calvinh99 @phisanti Yes, the request URL ends up with media.fields as a URL parameter key, but it requires a value as well and you need to pass the parameter individually through Tweepy, not as part of a different parameter.

@R2sh2 That’s not related to this issue. Client.get_users_tweets supports media.fields. Feel free to start a new discussion if you need help with using the parameter, but you’ll need to provide more information, like your code and expected and actual behavior.

0reactions
Harmon758commented, Aug 23, 2022

v4.10.1 has been released with this fix now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrieving media | Docs | Twitter Developer Platform
Media in direct messages must be retrieved via an authenticated app-user ... You can no longer access media via an authenticated www.twitter.com session....
Read more >
Getting User tweets by twitter API call not returning media_url
I am getting tweets of a user but not getting media_url under entities in right twitter object returned, even nothing in media in...
Read more >
How to Find Old Tweets: 4 Tried-And-True Methods
Learn how to find and delete old tweets, and easily remove dated or irrelevant content from your Twitter account.
Read more >
The Superhuman Guide to Twitter Advanced Search - Buffer
A look at all of the powerful uses of Twitter advanced search that pros use for marketing, research, competitor analysis, sales & more:...
Read more >
How to cite a tweet in APA Style | Format & examples - Scribbr
You'll list the year as “n.d.” (no date) and include a retrieval date, since the contents of the profile can change over time....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found