Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include JSON response in V2 requests #1989

Open
jdfoote opened this issue Oct 23, 2022 · 2 comments
Open

Include JSON response in V2 requests #1989

jdfoote opened this issue Oct 23, 2022 · 2 comments
Labels
Feature Request This is requesting a new feature RFC This is a Request For Comments

Comments

@jdfoote
Copy link

jdfoote commented Oct 23, 2022

The V1 requests include the raw JSON response, which I like to save as backup data. Would it be possible to have it included in the V2 responses as well? E.g., search_all_tweets?

@Harmon758
Copy link
Member

Harmon758 commented Oct 28, 2022

Note, setting return_type to dict for Client or AsyncClient will have their methods return the raw JSON as a dictionary.

I'm assuming that this is a feature request to include the raw JSON data in Response though, as that would allow Tweepy models to be used, while still having the raw JSON data available to save as backup data.

I'm considering changing Response based on this and other use cases, like #1984.
It would almost certainly be a breaking change though, so it would have to wait until a v5 release.

For now, as a workaround, with #1997, which resulted from a conversation about this in the Tweepy Discord server, you can use a requests.Response or dict return_type to access the JSON, headers, etc. before passing the JSON as a dictionary to Client._construct_response or AsyncClient._construct_response. Note, you'll also need to pass the data_type for any objects in data if you want them to be Tweepy models.

@Harmon758 Harmon758 added RFC This is a Request For Comments Feature Request This is requesting a new feature labels Oct 28, 2022
@jdfoote
Copy link
Author

jdfoote commented Oct 29, 2022

Thanks so much for the response (and for all of the work on tweepy!)

You have understood the request perfectly - I'd love to have the JSON included in the Response object.

This workaround seems great for now. Thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This is requesting a new feature RFC This is a Request For Comments
Projects
None yet
Development

No branches or pull requests

2 participants