Giter Club home page Giter Club logo

twitter-stream.py's Introduction

twitter-stream.py

๐Ÿ Python Client For Twitter API v2

Twitter APi V2 Twitter APi V2



๐Ÿš€ Why Twitter Stream ?

Twitter-Stream.py a python API client for Twitter API v2 now supports FilteredStream, SampledStream, RecentSearch, TweetLookUp, and UserLookUp. It makes it easier to get started with Twitter's New API. Let's see an example of how twitter-stream.py handles SampledStream. Sampled Stream delivers about 1% of Twitter's publicly available tweets in real-time and paints a picture of general sentiments, recent trends, and global events.

# sampled_stream.py

import json
from twitter_stream import SampledStream

class Stream(SampledStream):
    user_fields = ['name', 'location', 'public_metrics']
    expansions = ['author_id']
    tweet_fields = ['created_at']

stream = Stream()
for tweet in stream.connect():
    print(json.dumps(tweet, indent=4))

Is this all you have to do to start streaming? Yes. Are these all the data points available to you? No. Let's discuss line number 5-7. Twitter's Official Documentation lists an elaborate set of query parameters. You can use these queries to get the data you need. We are subclassing SampledStream and carefully constructing clear and eloquent queries in line 5-7. And you can do this for all the query parameters listed in the SampledStream API Reference.

To get more insights into other API endpoints. Visit the examples folder and our documentations twitivity.dev.

Installation

~$ pip3 install twitter-stream.py

Credentials

Store Twitter credentials at ~/.twitter-keys.yaml.

~$ vim ~/.twitter-keys.yaml
keys:
  consumer_key: CONSUMER_KEY
  consumer_secret: CONSUMER_SECRET
  access_token: ACCESS_TOKEN
  access_token_secret: ACCESS_TOKEN_SECRET
  bearer_token: BEARER_TOKEN

twitter-stream.py's People

Contributors

saadmanrafat avatar dependabot[bot] avatar tangent-tz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.