Skip to main content

✨✨ Twitter API Client by Typed Python ✨✨

Test Suite Package version

demo

Install

pip install twitter_api_py

Features

  • Fully type annotated.
  • OAuth1 / OAuth2 support.
  • Sync / Async Client support.
  • Mock Client support.

Usage

The simplest way to use the library is as follows:

from twitter_api import TwitterApiClient

response_body = (
    TwitterApiClient.from_oauth2_app_env()
    .request("https://api.twitter.com/2/tweets")
    .get({
        "ids": "1460323737035677698",
        "expansions": ["referenced_tweets.id"]
    })
)

As a characteristic feature of the library, it explicitly prompts the user to write the Endpoint URL, which makes it clear from the source code which Twitter API is being called.

Test Code

A mock client is provided by the library to simplify the writing of test code.

This client has the same interface as TwitterApiClient/TwitterApiAsyncClient, and also provides methods (inject_*_response_body) for injecting test data.

from twitter_api import TwitterApiClient, TwitterApiMockClient

def your_logic(twitter_client: TwitterApiClient):
    ...

def test_your_logic():
    twitter_client = (
        TwitterApiMockClient.from_oauth2_app_env()
        .inject_post_response_body("https://api.twitter.com/2/tweets", post_response_body)
        .inject_get_response_body("https://api.twitter.com/2/tweets/:id", get_response_body)
        .inject_delete_response_body("https://api.twitter.com/2/tweets", delete_response_body)
    )

    assert your_logic(twitter_client) is True

Metadata

Release files for twitter-api-py 0.9.0

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

Source distribution (sdist)

Source distribution for twitter-api-py 0.9.0
File Size Uploaded
twitter_api_py-0.9.0.tar.gz 63.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for twitter-api-py 0.9.0
File Interpreter ABI Platform
twitter_api_py-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 232.8 kB

Release files / twitter_api_py-0.9.0.tar.gz

Download URL twitter_api_py-0.9.0.tar.gz
Size 63.0 kB
Tags Source
SHA-256 checksum
How to use checksums
637e8af65870d9c3fd62fca472c5bf916bbf6fce6b295cd8d9ba62c02fcdb80c
BLAKE2b-256 checksum
How to use checksums
3aa89f48fa961dfe3ead6ce3776969f35b5722b6bb808a37eb154f60f0b57186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1039-azure

Release files / twitter_api_py-0.9.0-py3-none-any.whl

Download URL twitter_api_py-0.9.0-py3-none-any.whl
Size 169.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de6876f89e4fb9278727505e2eac74cbeb063560ac521d5964c8bd7d158e1681
BLAKE2b-256 checksum
How to use checksums
47756a763b0baeba083ed717d97cffef75545da13d2bdc8b9bd1be67feea6ba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1039-azure

Release history Release notifications | RSS feed

This release

0.9.0 This release

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.14

2 release files

0.4.13

2 release files

0.4.12

1 release file

0.4.11

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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