Skip to main content

Setup twitpy

Let's install twitpy first.

pip install twitpy

Now you need to actually setup the module by registring the 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 module.

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

Now you have succesfully accessed the module, Now you will be able to use it's features.

Picking user from retweet (retweet picker)

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

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

In the parenthesis of pickuserfrom_retweet 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

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

In the parenthesis of get_tweetsfromuser you write the Username first then you write the amount of tweets you want from the user, the number of tweets should be under 10. gettweets will return 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

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

In the parenthesis of find_user you 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

Access.retweet_tweet(258296982689)

In the parenthesis of retweet_tweet you write the tweet Id.

Following a user.

Access.follow_user("OHrefineddev")

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

Sending direct messages.

Access.send_dm("OHrefineddev","Hello, i love your twitpy Module."})

In the parenthesis of send_dm you write the user's username and the text you want to send to the user.

Note: There is a chance of this function to error most probably of the user you are trying to send the message is not following you, or the user has their DMs off.

Liking a status (tweet)

Access.like_tweet(138924958259208) 

In the parenthesis of like_tweet you write the Status (tweet) id.

Unliking a status (tweet)

Access.unlike_tweet(138924958259208)

In the parenthesis of unlike_tweet you write the Status (tweet) id.

More Features Coming Soon.

Metadata

Release files for twitpy 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for twitpy 1.0.3
File Interpreter ABI Platform
twitpy-1.0.3-py3-none-any.whl Python 3 none any Details

Release files / twitpy-1.0.3-py3-none-any.whl

Download URL twitpy-1.0.3-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
729ce393190db44736bf91d87071ad39707e8b9fb87c8b8985c96cc758acd14c
BLAKE2b-256 checksum
How to use checksums
afd17a1a580b9d09922668973bc2c9db00edcbd64752a9367145bae17613eae0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.9

Release history Release notifications | RSS feed

This release

1.0.3 This release

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page