birdapi 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bird/__init__.py +16 -0
- bird/_config.py +63 -0
- bird/_constants.py +48 -0
- bird/_features.py +256 -0
- bird/_models.py +92 -0
- bird/_query_ids.py +211 -0
- bird/_utils.py +491 -0
- bird/cli.py +769 -0
- bird/client.py +1702 -0
- birdapi-0.0.1.dist-info/METADATA +207 -0
- birdapi-0.0.1.dist-info/RECORD +14 -0
- birdapi-0.0.1.dist-info/WHEEL +4 -0
- birdapi-0.0.1.dist-info/entry_points.txt +2 -0
- birdapi-0.0.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: birdapi
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: CLI and library for X/Twitter GraphQL API (cookie auth, no API key required)
|
|
5
|
+
Project-URL: Homepage, https://github.com/dvermaas/birdapi
|
|
6
|
+
Project-URL: Repository, https://github.com/dvermaas/birdapi
|
|
7
|
+
Project-URL: Issues, https://github.com/dvermaas/birdapi/issues
|
|
8
|
+
Author: dvermaas
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: api,cli,graphql,twitter,x
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Internet
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: click>=8.1
|
|
25
|
+
Requires-Dist: httpx>=0.27
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# bird 🐦
|
|
34
|
+
|
|
35
|
+
A Python CLI and library for X/Twitter's GraphQL API using cookie-based authentication — no API key required.
|
|
36
|
+
|
|
37
|
+
> **Disclaimer:** This uses X/Twitter's undocumented internal GraphQL API. X can change endpoints or rotate query IDs at any time. Expect occasional breakage.
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e .
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Requires Python 3.10+.
|
|
46
|
+
|
|
47
|
+
## Quick start
|
|
48
|
+
|
|
49
|
+
### 1. Configure credentials
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
python -m bird.cli configure
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You'll be prompted for two cookies from your active X/Twitter session:
|
|
56
|
+
|
|
57
|
+
1. Open [x.com](https://x.com) and log in
|
|
58
|
+
2. Open DevTools → Application → Cookies → `https://x.com`
|
|
59
|
+
3. Copy the values of **`auth_token`** and **`ct0`**
|
|
60
|
+
|
|
61
|
+
Credentials are saved to `~/.config/bird/credentials.json` and used automatically by all commands.
|
|
62
|
+
|
|
63
|
+
### 2. Run commands
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
python -m bird.cli whoami
|
|
67
|
+
python -m bird.cli search "from:username" -n 10
|
|
68
|
+
python -m bird.cli tweet "Hello from Python"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Commands
|
|
72
|
+
|
|
73
|
+
| Command | Description |
|
|
74
|
+
|---|---|
|
|
75
|
+
| `configure` | Save credentials interactively |
|
|
76
|
+
| `whoami` | Show the authenticated account |
|
|
77
|
+
| `check` | Show where credentials are loaded from |
|
|
78
|
+
| `tweet "<text>"` | Post a new tweet |
|
|
79
|
+
| `reply <id-or-url> "<text>"` | Reply to a tweet |
|
|
80
|
+
| `read <id-or-url>` | Fetch a tweet |
|
|
81
|
+
| `thread <id-or-url>` | Show the full conversation thread |
|
|
82
|
+
| `replies <id-or-url>` | List replies to a tweet |
|
|
83
|
+
| `search "<query>"` | Search for tweets |
|
|
84
|
+
| `mentions` | Find tweets mentioning you |
|
|
85
|
+
| `user-tweets @handle` | Get tweets from a user's timeline |
|
|
86
|
+
| `home` | Your "For You" timeline |
|
|
87
|
+
| `home --following` | Your "Following" timeline |
|
|
88
|
+
| `bookmarks` | List your bookmarks |
|
|
89
|
+
| `unbookmark <id-or-url>` | Remove a bookmark |
|
|
90
|
+
| `likes` | List your liked tweets |
|
|
91
|
+
| `following` | Users you follow |
|
|
92
|
+
| `followers` | Users that follow you |
|
|
93
|
+
| `lists` | Your owned lists |
|
|
94
|
+
| `list-timeline <id-or-url>` | Tweets from a list |
|
|
95
|
+
| `news` | News and trending topics from Explore |
|
|
96
|
+
| `about @handle` | "About this account" info |
|
|
97
|
+
| `query-ids` | Inspect or refresh GraphQL query ID cache |
|
|
98
|
+
|
|
99
|
+
### Common options
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
--json Output raw JSON
|
|
103
|
+
-n / --count N Number of results (default varies per command)
|
|
104
|
+
--cursor STRING Resume pagination from a cursor
|
|
105
|
+
--max-pages N Limit number of pages fetched
|
|
106
|
+
--timeout MS Request timeout in milliseconds
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Auth options (override saved credentials)
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
--auth-token TOKEN
|
|
113
|
+
--ct0 TOKEN
|
|
114
|
+
|
|
115
|
+
# Or via environment variables
|
|
116
|
+
AUTH_TOKEN=... CT0=... python -m bird.cli whoami
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Examples
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Search and output JSON
|
|
123
|
+
python -m bird.cli search "python asyncio" -n 20 --json
|
|
124
|
+
|
|
125
|
+
# Get someone's recent tweets
|
|
126
|
+
python -m bird.cli user-tweets @gvanrossum -n 50
|
|
127
|
+
|
|
128
|
+
# Fetch a full thread
|
|
129
|
+
python -m bird.cli thread https://x.com/user/status/1234567890123456789
|
|
130
|
+
|
|
131
|
+
# List bookmarks from a specific folder
|
|
132
|
+
python -m bird.cli bookmarks --folder-id 1234567890123456789 -n 50
|
|
133
|
+
|
|
134
|
+
# Fetch AI-curated news
|
|
135
|
+
python -m bird.cli news --ai-only -n 10
|
|
136
|
+
|
|
137
|
+
# Paginate following list
|
|
138
|
+
python -m bird.cli following -n 200 --json
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Library usage
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from bird import TwitterClient
|
|
145
|
+
|
|
146
|
+
client = TwitterClient(auth_token="...", ct0="...")
|
|
147
|
+
|
|
148
|
+
# Search
|
|
149
|
+
tweets, next_cursor = client.search("from:gvanrossum", count=20)
|
|
150
|
+
for tweet in tweets:
|
|
151
|
+
print(f"@{tweet.author.username}: {tweet.text}")
|
|
152
|
+
|
|
153
|
+
# Post
|
|
154
|
+
tweet_id = client.tweet("Hello from Python!")
|
|
155
|
+
|
|
156
|
+
# Reply
|
|
157
|
+
client.reply("Thanks!", reply_to_tweet_id=tweet_id)
|
|
158
|
+
|
|
159
|
+
# Bookmarks
|
|
160
|
+
tweets, cursor = client.get_bookmarks(count=50)
|
|
161
|
+
|
|
162
|
+
# Engagement
|
|
163
|
+
client.like(tweet_id)
|
|
164
|
+
client.retweet(tweet_id)
|
|
165
|
+
client.bookmark(tweet_id)
|
|
166
|
+
|
|
167
|
+
# News
|
|
168
|
+
items = client.get_news(count=10, ai_only=True)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Context manager
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
with TwitterClient(auth_token="...", ct0="...") as client:
|
|
175
|
+
user = client.get_current_user()
|
|
176
|
+
print(user.username)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## Project structure
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
src/bird/
|
|
183
|
+
client.py TwitterClient — all API methods
|
|
184
|
+
cli.py Click CLI entry point
|
|
185
|
+
_config.py Credential storage (~/.config/bird/credentials.json)
|
|
186
|
+
_constants.py API URLs, bearer token, fallback query IDs
|
|
187
|
+
_features.py GraphQL feature-flag payloads
|
|
188
|
+
_models.py Dataclasses: Tweet, User, TwitterList, NewsItem, …
|
|
189
|
+
_utils.py Response parsing utilities
|
|
190
|
+
_query_ids.py Runtime query ID cache (scraped from x.com bundles)
|
|
191
|
+
tests/
|
|
192
|
+
test_utils.py Unit tests (no network required)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Development
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
pip install -e ".[dev]"
|
|
199
|
+
pytest tests/
|
|
200
|
+
ruff check src/ tests/
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Credential resolution order
|
|
204
|
+
|
|
205
|
+
1. `--auth-token` / `--ct0` CLI flags
|
|
206
|
+
2. `AUTH_TOKEN` / `CT0` environment variables
|
|
207
|
+
3. `~/.config/bird/credentials.json` (written by `bird configure`)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
bird/__init__.py,sha256=fYx62s_bLwJg-XiAAK2795Cy_0k-_wd4xovNac1IRaE,360
|
|
2
|
+
bird/_config.py,sha256=nHbop9NA55VfV7xFvyE0GODpOnblG0aE42XqVCxoarg,1621
|
|
3
|
+
bird/_constants.py,sha256=y4tOdQ9BXIdnTuVB0EmUijjfWNP8muCCqjueW3TBmPw,2094
|
|
4
|
+
bird/_features.py,sha256=7izFXwMnfyQwJRv8eOr8d0_Q4BSg4Yd5wbv5P3sf5fo,12051
|
|
5
|
+
bird/_models.py,sha256=AI5XA1cPtR8yNMtU04pCrlNcEXvO0cCzlSh8DyGypxg,2240
|
|
6
|
+
bird/_query_ids.py,sha256=OUq4-YR0nVPnc1LqGNwiKEO9cKk2w0SC1cfx4VjC1L0,7141
|
|
7
|
+
bird/_utils.py,sha256=zr_alBlA1Vx3pGkN97SwW_bE5-l2iZvV9BMhTvAGas8,17414
|
|
8
|
+
bird/cli.py,sha256=eGt00_GRIKubRbcUFsl_0XzyvQSrmYAy1PG8AKJ3-Ew,27848
|
|
9
|
+
bird/client.py,sha256=cHiavKuRvFhc8cnusmybDj2XLBRkQuQr_DGrmUpdmJU,69518
|
|
10
|
+
birdapi-0.0.1.dist-info/METADATA,sha256=n-WQXHAe09zkNC_rixbr2RQSjW0PZ9MNSmZLK4htsE8,5870
|
|
11
|
+
birdapi-0.0.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
12
|
+
birdapi-0.0.1.dist-info/entry_points.txt,sha256=SbDniUMeHC6oHAGSNcE2_IlvdbJswdROsJRKSuDDqJM,39
|
|
13
|
+
birdapi-0.0.1.dist-info/licenses/LICENSE,sha256=CXQjGE50cKMgjWufp1q1VRRlegfhaNxpOddqPgekm8k,1065
|
|
14
|
+
birdapi-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dvermaas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|