Skip to content

Instantly share code, notes, and snippets.

@andypiper
Created August 17, 2022 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andypiper/36e1a390026644eb6f7534ff459c7d40 to your computer and use it in GitHub Desktop.
Save andypiper/36e1a390026644eb6f7534ff459c7d40 to your computer and use it in GitHub Desktop.
Tweepy cheatsheet / Twitter API v2

BEARER = "my-long-token"

Check/delete stream rules

import tweepy

client = tweepy.StreamingClient(BEARER)

client.get_rules()

client.delete_rules(['ID1','ID2'])

pretty format data

    def on_data(self, data):
      data_obj = json.loads(data.decode('utf8'))
      print(json.dumps(data_obj,indent=2))
      return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment