✨✨ Twitter API Client by Typed Python ✨✨
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)
| File | Size | Uploaded | |
|---|---|---|---|
| twitter_api_py-0.9.0.tar.gz | 63.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|