SlyTwitter.twitter#

Twitter API v1.1

Functions

get_tweet_id(tweet)

Classes

Following(source)

Following relationship between two users, four possible states

Tweet(source)

Twitter(auth)

Twitter V1.1 API Client

User(source)

Twitter user, can be hydrated from a variety of sources

class SlyTwitter.twitter.User(source)[source]#

Bases: object

Twitter user, can be hydrated from a variety of sources

Parameters:

source (dict[str, Any]) –

display_name: str#
location: str | None = None#
website: str | None = None#
description: str | None = None#
is_verified: bool | None = None#
is_private: bool | None = None#
created_at: datetime.datetime | None = None#
profile_image: str | None = None#
id: int#
at: str#
class SlyTwitter.twitter.Following(source)[source]#

Bases: object

Following relationship between two users, four possible states

Parameters:

source (dict[str, Any]) –

a_follows_b: bool#
b_follows_a: bool#
mutual: bool#
a: User#
b: User#
class SlyTwitter.twitter.Tweet(source)[source]#

Bases: object

Parameters:

source (int | str | dict[str, Any]) –

id: int#
body: str#
author_at: str#
Return type:

str

SlyTwitter.twitter.get_tweet_id(tweet)[source]#
Parameters:

tweet (SlyTwitter.twitter.Tweet | int | str) –

Return type:

int

class SlyTwitter.twitter.Twitter(auth)[source]#

Bases: WebAPI

Twitter V1.1 API Client

Parameters:

auth (OAuth1) –

base_url: str = 'https://api.twitter.com/1.1'#
get_full_url(path)[source]#

Convert a relative path to an absolute url for this API

Parameters:

path (str) –

Return type:

str

await tweet(body, media=None)[source]#

Post a tweet. Media can be: - a file path - a URL - some media already uploaded - a bytes-like obj a tupled with a file extension

Parameters:
await check_follow(a, b)[source]#

Get the relationship between two users.

Parameters:
await delete(tweet)[source]#

Delete a tweet.

Parameters:

tweet (SlyTwitter.twitter.Tweet | int | str) –

await retweet(tweet)[source]#

Retweet a tweet.

Parameters:

tweet (SlyTwitter.twitter.Tweet | int | str) –

await quote_tweet(body, quoting, media=None)[source]#

Post a tweet quoting another tweet.

Parameters:
Return type:

Tweet

await upload_media(file_)[source]#

Upload a new media file to twitter for attaching to tweets. File can be: - a file path - a URL - a bytes-like obj a tupled with a file extension

Parameters:

file_ (str | tuple[bytes, str]) –

Return type:

Media

await add_alt_text(media, text)[source]#

Add alt text to a media file.

Parameters: