Skip to main content

A package based on the twitter api, search users of twitter and MORE!.

Project description

Setup twitpy

Let's install twitpy first and tweepy.

pip install twitpy
and
pip install tweepy

We are installing tweepy because i'm using tweepy to access the twitter API.

Now we need to actually setup the module by registring our API Keys.

import twitpy
Access = twitpy.accesstwitpy("access_token","access_token_secret","consumer_key","consumer_key_secret")

You need 4 API keys to access twitpy. You need a Twitter Developer Account for this, This is the MOST important step and without doing this you will not be able to access the API.

Learn more about Twitter Developer - https://developer.twitter.com/en

Now we have succesfully Accessed twitpy, Now we will use it's features.

Picking user from retweet (retweet picker)

Using the Access variable we defined before to gain access into twitpy we will now Use it's inbuilt retweet picker.

retweeted_winner = Access.pickuserfrom_retweet(131429358258)
print(retweeted_winner.username)

In the parenthesis of pickuserfrom_retweet we specify the tweet ID, if the tweet id is valid and it has more than 0 retweets it will pick a user, pickuserfrom_retweet returns the following attributes you can use.

username
name
userid
followers
following

Getting tweets from a user

Now we will use the Access Variable to get a specific amount of tweets (< 10) from a user.

gettweets = Access.get_tweetsfromuser("OHrefineddev",10)
for i in gettweets:
    print(i.full_text)

In the parenthesis of get_tweetsfromuser we write the Username first then we write the amount of tweets we want from the user, the number of tweets should be under 10,because gettweets was a list due to having 10 tweets it has to be looped through, get_tweetsfromuser returns the following attributes.

full_text
id
favorite_count : Likes
retweet_count : Retweets
created_at
source

Finding a user on twitter

Now we will use the Access Variable to find a user on twitter.

user = Access.find_user("OHrefineddev")
print(user.userid)

In the parenthesis of find_user we write the user's username, find_user returns the following attributes.

username
name
userid
created_at
description
followers
following
location
tweets_count : Total tweets from the user.
isVerified
avatar_url

Retweeting A Tweet

Now we will use the Access Variable to retweet a tweet on twitter.

Access.retweet_tweet(258296982689)

In the parenthesis of retweet_tweet we write the tweet Id.

#Following a user. Now we will use the Access Variable to follow a user on twitter.

Access.follow_user("OHrefineddev")

In the parenthesis of follow_user we write the User's username.

More Features Coming Soon.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

twitpy-0.0.5-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page