DEV Community

Pavan Gole
Pavan Gole

Posted on

How to get data in json format from tweepy.Client() ?

Top comments (1)

Collapse
 
nestedsoftware profile image
Nested Software • Edited

When you get your tweepy.Client object, you can specify your desired return type:

docs.tweepy.org/en/stable/client.h...

The default is Response but you can ask for dict instead, e.g. set return_type=dict when you make your call to tweepy.Client. This will cause your subsequent calls to return a standard python 3 dictionary. You should then be able to convert that dictionary to json using python's json.dumps:

docs.python.org/3/library/json.html

Another option is to convert the Response object to a dict:

docs.python.org/3/library/collecti...