jetblack_tweeter.api

class Account

Summary

Initialise the account endpoint api

jetblack_tweeter.api.Account(
client: AbstractHttpClient
) -> None

Parameters

client: AbstractHttpClient

The authenticated client.

async method Account.settings

Summary

Returns settings (including current trend, geo and sleep time

Description

information) for the authenticating user.

async Account.settings(
timeout: Optional[float]
) -> Mapping[str, Any]

Parameters

timeout: Optional[float] (optional)

If specified the timeout for the request. Defaults to None.

Returns

Mapping[str, Any]: The account settings.

async method Account.verify_credentials

Summary

Returns an HTTP 200 OK response code and a representation of the

Description

requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.

async Account.verify_credentials(
include_entities: Optional[bool],
skip_status: Optional[bool],
include_email: Optional[bool],
timeout: Optional[float]
) -> Mapping[str, Any]

Parameters

include_entities: Optional[bool] (optional)

The entities node will not be included when set to false. Defaults to None.

skip_status: Optional[bool] (optional)

When set to true statuses will not be included in the returned user object. Defaults to None.

include_email: Optional[bool] (optional)

When set to true email will be returned in the user objects as a string. If the user does not have an email address on their account, or if the email address is not verified, null will be returned. Defaults to None.

timeout: Optional[float] (optional)

If specified the timeout for the request. Defaults to None.

Returns

Mapping[str, Any]: User account details

Summary

Initialise the search endpoint api

jetblack_tweeter.api.Search(
client: AbstractHttpClient
) -> None

Parameters

client: AbstractHttpClient

The authenticated client.

async method Search.tweets

Summary

Returns a collection of relevant Tweets matching a specified query.

async Search.tweets(
q: str,
*,
geocode: Optional[Tuple[Number, Number, str]],
lang: Optional[str],
locale: Optional[str],
result_type: Optional[SearchResultType],
count: Optional[int],
until: Optional[date],
since_id: Optional[int],
max_id: Optional[int],
include_entities: Optional[bool],
timeout: Optional[float]
) -> List[Mapping[str, Any]]

Parameters

q: str

A UTF-8, URL-encoded search query of 500 characters maximum, including operators. Queries may additionally be limited by complexity.

geocode: Optional[Tuple[Number, Number, str]] (optional)

Returns tweets by users located within a given radius of the given latitude/longitude. The location is preferentially taking from the Geotagging API, but will fall back to their Twitter profile. The parameter value is specified by "latitude,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers). Note that you cannot use the near operator via the API to geocode arbitrary locations; however you can use this geocode parameter to search near geocodes directly. A maximum of 1,000 distinct "sub-regions" will be considered when using the radius modifier. Defaults to None.

lang: Optional[str] (optional)

Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort. Defaults to None.

locale: Optional[str] (optional)

Specify the language of the query you are sending (only ja is currently effective). This is intended for language-specific consumers and the default should work in the majority of cases. Defaults to None.

result_type: Optional[SearchResultType] (optional)

Specifies what type of search results you would prefer to receive. The current default is "mixed". Defaults to None.

count: Optional[int] (optional)

The number of tweets to return per page, 15 if unspecified, up to a maximum of 100. Defaults to None.

until: Optional[date] (optional)

Returns tweets created before the given date. Date should be formatted as YYYY-MM-DD. Keep in mind that the search index has a 7-day limit. In other words, no tweets will be found for a date older than one week. Defaults to None.

since_id: Optional[int] (optional)

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occurred since the since_id, the since_id will be forced to the oldest ID available. Defaults to None.

max_id: Optional[int] (optional)

Returns results with an ID less than (that is, older than) or equal to the specified ID. Defaults to None.

include_entities: Optional[bool] (optional)

The entities node will not be included when set to false. Defaults to None.

timeout: Optional[float] (optional)

If specified the timeout for the request. Defaults to None.

Returns

List[Mapping[str, Any]]: A list of matching tweets.

class Statuses

Summary

Initialise the statuses end point.

jetblack_tweeter.api.Statuses(
client: AbstractHttpClient
) -> None

Parameters

client: AbstractHttpClient

THe authenticated HTTP client

async method Statuses.destroy

Summary

Destroys the status specified by the required ID parameter. The

Description

authenticating user must be the author of the specified status. Returns the destroyed status if successful.

async Statuses.destroy(
status_id: int,
*,
trim_user: Optional[bool],
timeout: Optional[float]
) -> Mapping[str, Any]

Parameters

status_id: int

The numerical ID of the desired status.

trim_user: Optional[bool] (optional)

When set true each tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object. Defaults to None.

timeout: Optional[float] (optional)

If specified the timeout for the request. Defaults to None.

Returns

Mapping[str, Any]: THe deleted tweet.

async method Statuses.home_timeline

Summary

Returns a collection of the most recent Tweets and Retweets posted by

Description

the authenticating user and the users they follow. The home timeline is central to how most users interact with the Twitter service.

async Statuses.home_timeline(
*,
count: int,
since_id: Optional[int],
max_id: Optional[int],
trim_user: bool,
exclude_replies: bool,
include_entities: bool,
timeout: Optional[float]
) -> Mapping[str, Any]

Parameters

count: int (optional)

Specifies the number of records to retrieve. Must be less than or equal to 200. Defaults to 20. The value of count is best thought of as a limit to the number of tweets to return because suspended or deleted content is removed after the count has been applied. Defaults to 20.

since_id: Optional[int] (optional)

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occurred since the since_id, the since_id will be forced to the oldest ID available. Defaults to None.

max_id: Optional[int] (optional)

Returns results with an ID less than (that is, older than) or equal to the specified ID. Defaults to None.

trim_user: bool (optional)

When true each Tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object. Defaults to True.

exclude_replies: bool (optional)

This parameter will prevent replies from appearing in the returned timeline. Using exclude_replies with the count parameter will mean you will receive up-to count Tweets — this is because the count parameter retrieves that many Tweets before filtering out retweets and replies. Defaults to True.

include_entities: bool (optional)

The entities node will not be included when set to false. Defaults to False.

timeout: Optional[float] (optional)

If specified the timeout for the request. Defaults to None.

Returns

Mapping[str, Any]: The user timeline.

async method Statuses.lookup

Summary

Returns fully-hydrated Tweet objects for up to 100 Tweets per

Description

request, as specified by comma-separated values passed to the ids parameter.

async Statuses.lookup(
ids: List[int],
*,
include_entities: Optional[bool],
trim_user: Optional[bool],
map: Optional[bool],
include_ext_alt_text: Optional[bool],
include_card_uri: Optional[bool],
timeout: Optional[float]
) -> List[Mapping[str, Any]]

Parameters

ids: List[int]

A list of Tweet IDs, up to 100 are allowed in a single request.

include_entities: Optional[bool] (optional)

The entities node that may appear within embedded statuses will not be included when set to false. Defaults to None.

trim_user: Optional[bool] (optional)

When set to true each Tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object. Defaults to None.

map: Optional[bool] (optional)

When using the map parameter, Tweets that do not exist or cannot be viewed by the current user will still have their key represented but with an explicitly null value paired with it. Defaults to None.

include_ext_alt_text: Optional[bool] (optional)

If alt text has been added to any attached media entities, this parameter will return an ext_alt_text value in the top-level key for the media entity. If no value has been set, this will be returned as null. Defaults to None.

include_card_uri: Optional[bool] (optional)

When set to true each Tweet returned will include a card_uri attribute when there is an ads card attached to the Tweet and when that card was attached using the card_uri value. Defaults to None.

timeout: Optional[float] (optional)

If specified the timeout for the request. Defaults to None.

Returns

List[Mapping[str, Any]]: A list of tweets.

async method Statuses.mentions_timeline

Summary

Returns the 20 most recent mentions (Tweets containing a users's

Description

@screen_name) for the authenticating user.

async Statuses.mentions_timeline(
*,
count: Optional[int],
since_id: Optional[int],
max_id: Optional[int],
trim_user: bool,
include_entities: bool,
timeout: Optional[float]
) -> List[Mapping[str, Any]]

Parameters

count: Optional[int] (optional)

Specifies the number of Tweets to try and retrieve, up to a maximum of 200. The value of count is best thought of as a limit to the number of tweets to return because suspended or deleted content is removed after the count has been applied. We include retweets in the count, even if include_rts is not supplied. It is recommended you always send include_rts=1 when using this API method.. Defaults to None.

since_id: Optional[int] (optional)

Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occurred since the since_id, the since_id will be forced to the oldest ID available. Defaults to None.

max_id: Optional[int] (optional)

Returns results with an ID less than (that is, older than) or equal to the specified ID. Defaults to None.

trim_user: bool (optional)

When true each tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object. Defaults to True.

include_entities: bool (optional)

The entities node will not be included when set to false. Defaults to True.

timeout: Optional[float] (optional)

If specified the timeout for the request. Defaults to None.

Returns

List[Mapping[str, Any]]: The mentions timeline.

async method Statuses.oembed

Summary

Returns a single Tweet, specified by either a Tweet web URL or the

Description

Tweet ID, in an oEmbed-compatible format.

async Statuses.oembed(
url: str,
*,
maxwidth: Optional[int],
hide_media: Optional[bool],
hide_thread: Optional[bool],
omit_script: Optional[bool],
align: Optional[Alignment],
related: Optional[List[str]],
lang: Optional[str],
theme: Optional[Theme],
link_color: Optional[str],
widget_type: Optional[WidgetType],
dnt: Optional[bool],
timeout: Optional[float]
) -> Mapping[str, Any]

Parameters

url: str

The URL of the Tweet to be embedded

maxwidth: Optional[int] (optional)

The maximum width of a rendered Tweet in whole pixels. A supplied value under or over the allowed range will be returned as the minimum or maximum supported width respectively; the reset width value will be reflected in the returned width property. Note that Twitter does not support the oEmbed maxheight parameter. Tweets are fundamentally text, and are therefore of unpredictable height that cannot be scaled like an image or video. Relatedly, the oEmbed response will not provide a value for height. Implementations that need consistent heights for Tweets should refer to the hide_thread and hide_media parameters below. Defaults to None.

hide_media: Optional[bool] (optional)

When set to true links in a Tweet are not expanded to photo, video, or link previews. Defaults to None.

hide_thread: Optional[bool] (optional)

When set to true a collapsed version of the previous Tweet in a conversation thread will not be displayed when the requested Tweet is in reply to another Tweet. Defaults to None.

omit_script: Optional[bool] (optional)

When set to true the