xippios-x 0.1.0__tar.gz
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.
- xippios_x-0.1.0/.gitignore +27 -0
- xippios_x-0.1.0/CHANGELOG.md +132 -0
- xippios_x-0.1.0/LICENSE +201 -0
- xippios_x-0.1.0/PKG-INFO +128 -0
- xippios_x-0.1.0/README.md +99 -0
- xippios_x-0.1.0/docs/upstream/FETCHED.md +90 -0
- xippios_x-0.1.0/docs/upstream/openapi/openapi.json +44259 -0
- xippios_x-0.1.0/docs/upstream/pages/application-only.md +225 -0
- xippios_x-0.1.0/docs/upstream/pages/fields.md +201 -0
- xippios_x-0.1.0/docs/upstream/pages/oauth-2-0.md +30 -0
- xippios_x-0.1.0/docs/upstream/pages/pagination.md +197 -0
- xippios_x-0.1.0/docs/upstream/pages/post-counts.md +167 -0
- xippios_x-0.1.0/docs/upstream/pages/pricing.md +298 -0
- xippios_x-0.1.0/docs/upstream/pages/rate-limits.md +491 -0
- xippios_x-0.1.0/docs/upstream/pages/response-codes-and-errors.md +228 -0
- xippios_x-0.1.0/docs/upstream/pages/search-operators.md +206 -0
- xippios_x-0.1.0/docs/upstream/pages/usage-and-billing.md +146 -0
- xippios_x-0.1.0/docs/upstream/pages/usage.md +114 -0
- xippios_x-0.1.0/docs/upstream/terms/developer-agreement.md +182 -0
- xippios_x-0.1.0/docs/upstream/terms/developer-policy.md +257 -0
- xippios_x-0.1.0/pyproject.toml +109 -0
- xippios_x-0.1.0/src/xippios/x/__init__.py +52 -0
- xippios_x-0.1.0/src/xippios/x/_client.py +198 -0
- xippios_x-0.1.0/src/xippios/x/_version.py +10 -0
- xippios_x-0.1.0/src/xippios/x/api/__init__.py +32 -0
- xippios_x-0.1.0/src/xippios/x/api/_query.py +135 -0
- xippios_x-0.1.0/src/xippios/x/api/get_lists_members.py +80 -0
- xippios_x-0.1.0/src/xippios/x/api/get_lists_posts.py +84 -0
- xippios_x-0.1.0/src/xippios/x/api/get_posts_by_ids.py +72 -0
- xippios_x-0.1.0/src/xippios/x/api/get_posts_counts_all.py +84 -0
- xippios_x-0.1.0/src/xippios/x/api/get_posts_counts_recent.py +82 -0
- xippios_x-0.1.0/src/xippios/x/api/get_usage.py +56 -0
- xippios_x-0.1.0/src/xippios/x/api/get_users_by_usernames.py +73 -0
- xippios_x-0.1.0/src/xippios/x/api/get_users_posts.py +92 -0
- xippios_x-0.1.0/src/xippios/x/api/search_posts_recent.py +131 -0
- xippios_x-0.1.0/src/xippios/x/enums.py +3 -0
- xippios_x-0.1.0/src/xippios/x/errors.py +11 -0
- xippios_x-0.1.0/src/xippios/x/http.py +18 -0
- xippios_x-0.1.0/src/xippios/x/mcp.py +33 -0
- xippios_x-0.1.0/src/xippios/x/models.py +1007 -0
- xippios_x-0.1.0/src/xippios/x/params.py +12 -0
- xippios_x-0.1.0/src/xippios/x/py.typed +0 -0
- xippios_x-0.1.0/src/xippios/x/reference/README.md +13 -0
- xippios_x-0.1.0/src/xippios/x/tasks.py +511 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# environments and caches
|
|
2
|
+
.venv/
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
.mypy_cache/
|
|
6
|
+
.ruff_cache/
|
|
7
|
+
.pytest_cache/
|
|
8
|
+
.hypothesis/
|
|
9
|
+
|
|
10
|
+
# build artefacts
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
|
|
15
|
+
# local secrets are never files, but belt and braces
|
|
16
|
+
.env
|
|
17
|
+
.env.*
|
|
18
|
+
.envrc
|
|
19
|
+
.envrc.*
|
|
20
|
+
|
|
21
|
+
# operator-only files: the curated account list, the probe's cache and its reports
|
|
22
|
+
# (CLAUDE.md, Operator-only files); X Content never leaves this directory
|
|
23
|
+
.local/
|
|
24
|
+
|
|
25
|
+
# editors
|
|
26
|
+
.idea/
|
|
27
|
+
.vscode/
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/) (pre-1.0: breaking changes bump the minor).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-10-30
|
|
10
|
+
|
|
11
|
+
First release, on xippios-core 0.3.0 from PyPI (`~=0.3.0`), sdk-template v0.3.0 and
|
|
12
|
+
conventions 1.24, under ADR-0027, which sets the rules for X, the family's first
|
|
13
|
+
upstream that bills in money rather than by quota. It reads X API v2 with the app's
|
|
14
|
+
Bearer Token and posts nothing: seven read tasks, `lookup_users`, `get_user_posts`,
|
|
15
|
+
`search_recent_posts`, `count_posts`, `get_list_posts`, `get_conversation_posts` and
|
|
16
|
+
`get_usage`, each one request returning one page as X sends it, served as MCP tools and
|
|
17
|
+
HTTP routes over nine endpoint wrappers. Each call that returns data spends X credits at
|
|
18
|
+
the prices of X's pricing page, which each task's docstring names (the page states none
|
|
19
|
+
for `get_usage`), and the spending limit set in X's Developer Console is the hard stop:
|
|
20
|
+
a post task reads at most 100 posts a call, 0.50 USD, `lookup_users` at most 100 users,
|
|
21
|
+
1.00 USD (1.50 USD with their most recent posts), a count costs 0.010 USD a request, and
|
|
22
|
+
the nightly live run spends one lookup, about 0.010 USD. Posting and reads in a user's
|
|
23
|
+
context are not part of it. Nothing was published before, so the entries under Changed
|
|
24
|
+
record steps on the way to this release.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Scaffold from [sdk-template](https://github.com/xippios/sdk-template): configured
|
|
29
|
+
client for X API v2, empty task layer, MCP server and FastAPI router
|
|
30
|
+
wired to it, test harness with core's family check, CI, the nightly live tests and
|
|
31
|
+
the release train, in which a release PR's merge tags and publishes.
|
|
32
|
+
- The upstream documentation snapshot in `docs/upstream/`, fetched 2026-10-29: X API v2's
|
|
33
|
+
OpenAPI document (version 2.173), the docs.x.com pages on pricing, usage and billing,
|
|
34
|
+
the usage endpoint, rate limits, response codes and errors, fields, pagination, post
|
|
35
|
+
counts and app-only Bearer Token authentication, and the X Developer Agreement and
|
|
36
|
+
Developer Policy, each kept as served, refreshed on 2026-10-30 with the search
|
|
37
|
+
operators page, which documents the query operators the tasks use;
|
|
38
|
+
`scripts/refresh_upstream.py` reproduces it and regenerates `FETCHED.md`.
|
|
39
|
+
- The four read wrappers the account probe needs, one page each as the OpenAPI
|
|
40
|
+
document's response model (`data`, `includes`, `errors`, `meta`):
|
|
41
|
+
`api.get_users_by_usernames`, `api.get_posts_by_ids`, `api.get_users_posts` and
|
|
42
|
+
`api.get_posts_counts_all`. Their parameters carry the document's names, which X takes
|
|
43
|
+
(`post.fields`, `expansions=most_recent_post_id`, `referenced_posts`), and values outside
|
|
44
|
+
the document's bounds are refused before the call. The models read both spellings X
|
|
45
|
+
answers in, the document's and the guides' (`most_recent_tweet_id`, `tweet_count`,
|
|
46
|
+
`includes.tweets`).
|
|
47
|
+
- `classify` maps X's answers to the error taxonomy: a 429 to `RateLimitError` with the
|
|
48
|
+
wait until `x-rate-limit-reset` (15 minutes when it is missing), a usage cap to
|
|
49
|
+
`RateLimitError` until the next billing cycle, a 400 to `InvalidRequestError`, a 404 to
|
|
50
|
+
`NotFoundError`. A 200 that carries errors is returned as the page.
|
|
51
|
+
- `scripts/record_fixture.py`, the fixture recorder: it records from @XDevelopers, @USDA
|
|
52
|
+
and @FAO only, prints its spend estimate first, and rewrites `text`, `description`, and
|
|
53
|
+
the `name`, `username` and `location` of every user other than those three accounts
|
|
54
|
+
before the fixture is written, counts as sent, within what the X Developer Agreement
|
|
55
|
+
allows of content given to third parties; the recorded fixtures of the four wrappers.
|
|
56
|
+
- Four more read wrappers, one page each as the OpenAPI document's response model:
|
|
57
|
+
`api.search_posts_recent` (recent search, with `SortOrder`), `api.get_posts_counts_recent`
|
|
58
|
+
(post counts over the last seven days), `api.get_lists_posts` (the posts of a List's
|
|
59
|
+
members) and `api.get_lists_members`, under the document's parameter names, values
|
|
60
|
+
outside its bounds and two parameters of which it allows one refused before the call.
|
|
61
|
+
Their fixtures are recorded from @USDA's posts and from a List @XDevelopers owns, the
|
|
62
|
+
members' names, handles, locations and bios rewritten.
|
|
63
|
+
- `scripts/record_fixture.py` records the four new wrappers: a recent search only for
|
|
64
|
+
`from:` one of @XDevelopers, @USDA and @FAO, alone or without reposts and replies, since
|
|
65
|
+
a search returns the posts it matches; a List only when one of the three owns it; a
|
|
66
|
+
List's members without their profile URL, which the rewrite does not cover.
|
|
67
|
+
- `scripts/probe_accounts.py`, the account probe: it reads the operator's account list,
|
|
68
|
+
prints its spend estimate and call plan without a request, and only with `--spend
|
|
69
|
+
--spend-cap` looks the accounts up, counts their posts and original posts by day over
|
|
70
|
+
90 days and samples ten posts each, waiting out X's rate-limit windows and keeping every
|
|
71
|
+
page in a same-day cache with a ledger of the day's spend; it writes a CSV and a
|
|
72
|
+
Markdown report with the go, US-only or no-go decision under `.local/`, which git now
|
|
73
|
+
ignores.
|
|
74
|
+
- The task layer, seven read tasks, each one request returning X's page as sent with its
|
|
75
|
+
release metadata: `lookup_users` (users by username, with their most recent post on
|
|
76
|
+
request), `get_user_posts`, `search_recent_posts` (512 characters of query at most),
|
|
77
|
+
`count_posts` (post counts over the full archive by hour, upstream's default, day or
|
|
78
|
+
minute, 1,024 characters of query at most), `get_list_posts`, `get_conversation_posts`
|
|
79
|
+
(a conversation's posts of the last seven days) and `get_usage` (the project's post
|
|
80
|
+
usage). Paging is the caller's, with the `next_token` of the previous page;
|
|
81
|
+
`max_results` defaults to 10 and goes up to 100, and each docstring names the price per
|
|
82
|
+
post, user or request. `meta.published_at` stays empty: X states no release time for a
|
|
83
|
+
page, and each post carries its own creation time. A user or List id X does not find,
|
|
84
|
+
or a lookup that finds nobody, raises `NotFoundError`.
|
|
85
|
+
- The MCP read server `xippios-x-mcp` and the FastAPI router serve the seven tasks as the
|
|
86
|
+
tools `x_lookup_users`, `x_get_user_posts`, `x_search_recent_posts`, `x_count_posts`,
|
|
87
|
+
`x_get_list_posts`, `x_get_conversation_posts` and `x_get_usage` and the routes under
|
|
88
|
+
`/x/`. The post tools' results are capped at 128,000 bytes and `x_lookup_users`' at
|
|
89
|
+
160,000, so a whole page of 100 posts or users comes back where its text is
|
|
90
|
+
Latin-script (mostly non-Latin text can still be cut); the other tools keep the family's
|
|
91
|
+
64 KB, which a month of hourly counts fits and minute counts over more than about 14
|
|
92
|
+
hours pass. A cut's note names the tool's own parameters.
|
|
93
|
+
- `api.get_usage`, the wrapper of `GET /2/usage/tweets`, with the `Usage` models and
|
|
94
|
+
`UsageField`; X answers in the OpenAPI document's shape, its counts as digit strings,
|
|
95
|
+
read as numbers.
|
|
96
|
+
- `scripts/record_fixture.py` records `get_usage`, which has no price on X's pricing page,
|
|
97
|
+
and a recent search for a conversation started by a post of @XDevelopers, @USDA or @FAO,
|
|
98
|
+
its replies' text rewritten; the fixtures of one @USDA conversation and of seven days of
|
|
99
|
+
usage.
|
|
100
|
+
- One live smoke test per task; the nightly run spends one billable call, the lookup of
|
|
101
|
+
@XDevelopers, and the other six run on demand and locally.
|
|
102
|
+
|
|
103
|
+
### Changed
|
|
104
|
+
|
|
105
|
+
- `CLAUDE.md`: the credential is the app's Bearer Token, not the console's API Key; the
|
|
106
|
+
rate-limit row names X's documented 15-minute windows beside the self-imposed pace; the
|
|
107
|
+
fixtures path is `<wrapper>/<case>.json`; the X API v2 specifics hold spend, the
|
|
108
|
+
fixtures decision with the Developer Agreement's clause, the nightly live run, the
|
|
109
|
+
operator-only `.local/` and the paths, names and errors the snapshot states; then the
|
|
110
|
+
names the wire takes and answers in, the recorder's rules and `classify`'s mapping; then
|
|
111
|
+
the probe, and the nightly run keyless until the probe's go.
|
|
112
|
+
- README: the Bearer Token in the key sentence, and the X Developer Agreement and
|
|
113
|
+
Developer Policy as the terms data comes under.
|
|
114
|
+
- The fixture `get_posts_by_ids/most_recent_three` is recorded again for the same three
|
|
115
|
+
posts without the `referenced_posts` expansion: it holds the three accounts' posts only,
|
|
116
|
+
and no fixture carries a post or profile of another account. The recorder admits one
|
|
117
|
+
expansion, `most_recent_post_id`, which brings a post of the requested user and no
|
|
118
|
+
profile; the wrappers keep every expansion the OpenAPI document lists.
|
|
119
|
+
- The hand-written enums (`UserField`, `PostField`, `UserExpansion`, `PostExpansion`,
|
|
120
|
+
`Granularity` and the schemas' value lists) name in their docstrings, which an MCP
|
|
121
|
+
tool's input schema shows, the OpenAPI document's list they come from, its version and
|
|
122
|
+
the snapshot's date.
|
|
123
|
+
- The account probe reads its list bare or under the one key `accounts:`, and refuses any
|
|
124
|
+
other shape by its type. Its list errors print no value from the list: an entry with
|
|
125
|
+
unknown fields is named by its position and their count, and where an unquoted comma
|
|
126
|
+
split a value in a one-line record, by the field to quote, `why` say; a list that is not
|
|
127
|
+
UTF-8 text is refused by its path, without a traceback. `CLAUDE.md` says how the list is
|
|
128
|
+
written.
|
|
129
|
+
- `CLAUDE.md`: the task layer (the tasks, their spend per call, fields, query limits,
|
|
130
|
+
paging, absence, metadata, the `published_at` rule and the MCP caps), the nightly live
|
|
131
|
+
run's rule and the recorder's conversation guard; README: the example, the MCP notes and
|
|
132
|
+
the status table of the seven tasks.
|
xippios_x-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
xippios_x-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: xippios-x
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Typed client, MCP tools and HTTP routes for X API v2
|
|
5
|
+
Project-URL: Homepage, https://github.com/xippios/sdk-x
|
|
6
|
+
Project-URL: Upstream, https://x.com
|
|
7
|
+
Project-URL: Changelog, https://github.com/xippios/sdk-x/blob/main/CHANGELOG.md
|
|
8
|
+
Project-URL: Issues, https://github.com/xippios/sdk-x/issues
|
|
9
|
+
Author: XIPPIOS GmbH
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: httpx,mcp,pydantic,sdk,x
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Requires-Dist: xippios-core~=0.3.0
|
|
22
|
+
Provides-Extra: http
|
|
23
|
+
Requires-Dist: xippios-core[http]~=0.3.0; extra == 'http'
|
|
24
|
+
Provides-Extra: mcp
|
|
25
|
+
Requires-Dist: xippios-core[mcp]~=0.3.0; extra == 'mcp'
|
|
26
|
+
Provides-Extra: testing
|
|
27
|
+
Requires-Dist: xippios-core[testing]~=0.3.0; extra == 'testing'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# xippios-x
|
|
31
|
+
|
|
32
|
+
Typed Python client, MCP server and FastAPI routes for
|
|
33
|
+
[X API v2](https://x.com), part of the
|
|
34
|
+
[xippios SDK family](https://github.com/xippios). Names and semantics follow the
|
|
35
|
+
upstream documentation; every response carries release metadata (source, endpoint,
|
|
36
|
+
retrieved_at, published_at, vintage).
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
uv add xippios-x # client only
|
|
42
|
+
uv add "xippios-x[mcp]" # + MCP server
|
|
43
|
+
uv add "xippios-x[http]" # + FastAPI router
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Set `X_API_KEY` in the environment to your X app's Bearer Token, which X also calls the
|
|
47
|
+
App only Access Token (Developer Console, Keys and tokens), not the console's API Key,
|
|
48
|
+
the OAuth 1.0a consumer key. Nothing is read from files.
|
|
49
|
+
|
|
50
|
+
## 30-second example
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from xippios.x import tasks
|
|
54
|
+
|
|
55
|
+
users = tasks.lookup_users(["USDA", "FAO"]) # 0.010 USD a user found
|
|
56
|
+
usda = next(user for user in users.data.data if user.username == "USDA")
|
|
57
|
+
|
|
58
|
+
page = tasks.get_user_posts(usda.id, max_results=10) # 0.005 USD a post returned
|
|
59
|
+
for post in page.data.data or []:
|
|
60
|
+
print(post.created_at, post.public_metrics.like_count, post.text)
|
|
61
|
+
print(page.meta.retrieved_at, page.meta.request, page.data.meta.result_count)
|
|
62
|
+
|
|
63
|
+
older = tasks.get_user_posts(usda.id, pagination_token=page.data.meta.next_token)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Every task returns one page as X sends it, in `result.data`; a call that returns data
|
|
67
|
+
spends X credits at the prices of X's pricing page, which each task's docstring names (the
|
|
68
|
+
page states none for `get_usage`). Paging is the caller's, with the `next_token` of the
|
|
69
|
+
previous page's `meta`. Underneath the tasks, `xippios.x.api` wraps nine X API v2
|
|
70
|
+
operations one page at a time (users by username, posts by id, a user's posts, post counts
|
|
71
|
+
over the archive, recent search, post counts over the last seven days, a List's posts, a
|
|
72
|
+
List's members and the project's usage).
|
|
73
|
+
|
|
74
|
+
## MCP
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"mcpServers": {
|
|
79
|
+
"x": {
|
|
80
|
+
"command": "uvx",
|
|
81
|
+
"args": ["--from", "xippios-x[mcp]", "xippios-x-mcp"],
|
|
82
|
+
"env": { "X_API_KEY": "..." }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`xippios-x-mcp` serves stdio; `--http` serves streamable HTTP instead. Tools are read-only
|
|
89
|
+
and named `x_<verb>_<noun>`; every call that returns data spends X credits, and each
|
|
90
|
+
tool's description gives its price (the pricing page states none for `x_get_usage`). A
|
|
91
|
+
tool returns one page, which its result cap holds whole for Latin-script text: up to 100
|
|
92
|
+
posts in 128,000 bytes, 100 users in 160,000, and 64 KB for the counts, which a month of
|
|
93
|
+
hourly buckets fits. A page of mostly non-Latin text, or minute counts over more than
|
|
94
|
+
about 14 hours, can be cut, with a note on how to see the rest.
|
|
95
|
+
|
|
96
|
+
## Status
|
|
97
|
+
|
|
98
|
+
<!-- Core's family check (tests/test_family.py) reads this table: keep the "## Status"
|
|
99
|
+
heading and the "Task function" column. Each row's Task function cell starts with the
|
|
100
|
+
task's name in backticks, alone or as its call (`get_data(code, year)`); several tasks in
|
|
101
|
+
one row are backticked names separated by commas; prose may follow. The tables list
|
|
102
|
+
exactly tasks.__all__. -->
|
|
103
|
+
|
|
104
|
+
| Upstream operation | Task function | MCP tool | Status |
|
|
105
|
+
| --- | --- | --- | --- |
|
|
106
|
+
| `GET /2/users/by` (`getUsersByUsernames`) | `lookup_users(usernames, most_recent_post)` | `x_lookup_users` | alpha; 0.010 USD a user, 0.005 USD more with `most_recent_post` |
|
|
107
|
+
| `GET /2/users/{id}/tweets` (`getUsersPosts`) | `get_user_posts(id, max_results, pagination_token, start_time, end_time)` | `x_get_user_posts` | alpha; 0.005 USD a post |
|
|
108
|
+
| `GET /2/tweets/search/recent` (`searchPostsRecent`) | `search_recent_posts(query, max_results, next_token, start_time, end_time)` | `x_search_recent_posts` | alpha; 0.005 USD a post; query of 512 characters at most |
|
|
109
|
+
| `GET /2/tweets/counts/all` (`getPostsCountsAll`) | `count_posts(query, granularity, start_time, end_time, next_token)` | `x_count_posts` | alpha; 0.010 USD a request; query of 1,024 characters at most |
|
|
110
|
+
| `GET /2/lists/{id}/tweets` (`getListsPosts`) | `get_list_posts(id, max_results, pagination_token)` | `x_get_list_posts` | alpha; 0.005 USD a post |
|
|
111
|
+
| `GET /2/tweets/search/recent` (`searchPostsRecent`, `conversation_id:`) | `get_conversation_posts(conversation_id, max_results, next_token)` | `x_get_conversation_posts` | alpha; 0.005 USD a post |
|
|
112
|
+
| `GET /2/usage/tweets` (`getUsage`) | `get_usage(days)` | `x_get_usage` | alpha; no price stated |
|
|
113
|
+
|
|
114
|
+
Prices are those of X's pricing page in the snapshot of 2026-10-29
|
|
115
|
+
(`docs/upstream/pages/pricing.md`); a post or user read again the same UTC day is not billed
|
|
116
|
+
again, a counts request always is.
|
|
117
|
+
|
|
118
|
+
## Upstream terms and attribution
|
|
119
|
+
|
|
120
|
+
Data comes from X API v2 (https://x.com) under the
|
|
121
|
+
[X Developer Agreement](https://docs.x.com/developer-terms/agreement) and the
|
|
122
|
+
[X Developer Policy](https://docs.x.com/developer-terms/policy), which bind every app that
|
|
123
|
+
uses it; this package adds no rights to it. Documentation snapshot and its attribution:
|
|
124
|
+
`docs/upstream/FETCHED.md`.
|
|
125
|
+
|
|
126
|
+
## Licence
|
|
127
|
+
|
|
128
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# xippios-x
|
|
2
|
+
|
|
3
|
+
Typed Python client, MCP server and FastAPI routes for
|
|
4
|
+
[X API v2](https://x.com), part of the
|
|
5
|
+
[xippios SDK family](https://github.com/xippios). Names and semantics follow the
|
|
6
|
+
upstream documentation; every response carries release metadata (source, endpoint,
|
|
7
|
+
retrieved_at, published_at, vintage).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv add xippios-x # client only
|
|
13
|
+
uv add "xippios-x[mcp]" # + MCP server
|
|
14
|
+
uv add "xippios-x[http]" # + FastAPI router
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Set `X_API_KEY` in the environment to your X app's Bearer Token, which X also calls the
|
|
18
|
+
App only Access Token (Developer Console, Keys and tokens), not the console's API Key,
|
|
19
|
+
the OAuth 1.0a consumer key. Nothing is read from files.
|
|
20
|
+
|
|
21
|
+
## 30-second example
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from xippios.x import tasks
|
|
25
|
+
|
|
26
|
+
users = tasks.lookup_users(["USDA", "FAO"]) # 0.010 USD a user found
|
|
27
|
+
usda = next(user for user in users.data.data if user.username == "USDA")
|
|
28
|
+
|
|
29
|
+
page = tasks.get_user_posts(usda.id, max_results=10) # 0.005 USD a post returned
|
|
30
|
+
for post in page.data.data or []:
|
|
31
|
+
print(post.created_at, post.public_metrics.like_count, post.text)
|
|
32
|
+
print(page.meta.retrieved_at, page.meta.request, page.data.meta.result_count)
|
|
33
|
+
|
|
34
|
+
older = tasks.get_user_posts(usda.id, pagination_token=page.data.meta.next_token)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Every task returns one page as X sends it, in `result.data`; a call that returns data
|
|
38
|
+
spends X credits at the prices of X's pricing page, which each task's docstring names (the
|
|
39
|
+
page states none for `get_usage`). Paging is the caller's, with the `next_token` of the
|
|
40
|
+
previous page's `meta`. Underneath the tasks, `xippios.x.api` wraps nine X API v2
|
|
41
|
+
operations one page at a time (users by username, posts by id, a user's posts, post counts
|
|
42
|
+
over the archive, recent search, post counts over the last seven days, a List's posts, a
|
|
43
|
+
List's members and the project's usage).
|
|
44
|
+
|
|
45
|
+
## MCP
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"mcpServers": {
|
|
50
|
+
"x": {
|
|
51
|
+
"command": "uvx",
|
|
52
|
+
"args": ["--from", "xippios-x[mcp]", "xippios-x-mcp"],
|
|
53
|
+
"env": { "X_API_KEY": "..." }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`xippios-x-mcp` serves stdio; `--http` serves streamable HTTP instead. Tools are read-only
|
|
60
|
+
and named `x_<verb>_<noun>`; every call that returns data spends X credits, and each
|
|
61
|
+
tool's description gives its price (the pricing page states none for `x_get_usage`). A
|
|
62
|
+
tool returns one page, which its result cap holds whole for Latin-script text: up to 100
|
|
63
|
+
posts in 128,000 bytes, 100 users in 160,000, and 64 KB for the counts, which a month of
|
|
64
|
+
hourly buckets fits. A page of mostly non-Latin text, or minute counts over more than
|
|
65
|
+
about 14 hours, can be cut, with a note on how to see the rest.
|
|
66
|
+
|
|
67
|
+
## Status
|
|
68
|
+
|
|
69
|
+
<!-- Core's family check (tests/test_family.py) reads this table: keep the "## Status"
|
|
70
|
+
heading and the "Task function" column. Each row's Task function cell starts with the
|
|
71
|
+
task's name in backticks, alone or as its call (`get_data(code, year)`); several tasks in
|
|
72
|
+
one row are backticked names separated by commas; prose may follow. The tables list
|
|
73
|
+
exactly tasks.__all__. -->
|
|
74
|
+
|
|
75
|
+
| Upstream operation | Task function | MCP tool | Status |
|
|
76
|
+
| --- | --- | --- | --- |
|
|
77
|
+
| `GET /2/users/by` (`getUsersByUsernames`) | `lookup_users(usernames, most_recent_post)` | `x_lookup_users` | alpha; 0.010 USD a user, 0.005 USD more with `most_recent_post` |
|
|
78
|
+
| `GET /2/users/{id}/tweets` (`getUsersPosts`) | `get_user_posts(id, max_results, pagination_token, start_time, end_time)` | `x_get_user_posts` | alpha; 0.005 USD a post |
|
|
79
|
+
| `GET /2/tweets/search/recent` (`searchPostsRecent`) | `search_recent_posts(query, max_results, next_token, start_time, end_time)` | `x_search_recent_posts` | alpha; 0.005 USD a post; query of 512 characters at most |
|
|
80
|
+
| `GET /2/tweets/counts/all` (`getPostsCountsAll`) | `count_posts(query, granularity, start_time, end_time, next_token)` | `x_count_posts` | alpha; 0.010 USD a request; query of 1,024 characters at most |
|
|
81
|
+
| `GET /2/lists/{id}/tweets` (`getListsPosts`) | `get_list_posts(id, max_results, pagination_token)` | `x_get_list_posts` | alpha; 0.005 USD a post |
|
|
82
|
+
| `GET /2/tweets/search/recent` (`searchPostsRecent`, `conversation_id:`) | `get_conversation_posts(conversation_id, max_results, next_token)` | `x_get_conversation_posts` | alpha; 0.005 USD a post |
|
|
83
|
+
| `GET /2/usage/tweets` (`getUsage`) | `get_usage(days)` | `x_get_usage` | alpha; no price stated |
|
|
84
|
+
|
|
85
|
+
Prices are those of X's pricing page in the snapshot of 2026-10-29
|
|
86
|
+
(`docs/upstream/pages/pricing.md`); a post or user read again the same UTC day is not billed
|
|
87
|
+
again, a counts request always is.
|
|
88
|
+
|
|
89
|
+
## Upstream terms and attribution
|
|
90
|
+
|
|
91
|
+
Data comes from X API v2 (https://x.com) under the
|
|
92
|
+
[X Developer Agreement](https://docs.x.com/developer-terms/agreement) and the
|
|
93
|
+
[X Developer Policy](https://docs.x.com/developer-terms/policy), which bind every app that
|
|
94
|
+
uses it; this package adds no rights to it. Documentation snapshot and its attribution:
|
|
95
|
+
`docs/upstream/FETCHED.md`.
|
|
96
|
+
|
|
97
|
+
## Licence
|
|
98
|
+
|
|
99
|
+
Apache-2.0. See [LICENSE](LICENSE).
|