Skip to main content

XKit for Python

GitHub stars GitHub commit activity PyPI version License

XKit for Python is a maintained Twitter/X web API client. It supports common Twitter/X actions such as login, posting, searching, timelines, trends, DMs, and media handling without an official developer API key.

Why XKit

Twitter/X keeps changing its web API, GraphQL query IDs, bundle formats, transaction ID logic, and response shapes. XKit focuses on keeping these workflows usable with active fixes for current Twitter/X behavior.

Recent maintenance work includes:

  • Updated ondemand.s webpack bundle lookup for current X bundle formats.
  • Refreshed SearchTimeline query ID, variables, and feature flags.
  • Defensive parsing for changed user, tweet, trend, and cursor payloads.
  • Rate-limit recursion guard for safer 429 handling.
  • Castle Token support for login and onboarding flows.
  • A JavaScript reference implementation for X client transaction ID generation.

Installation

pip install xkit-py

Use the xkit import path for new code:

from xkit import Client

The upstream-compatible twikit import path is still available for existing code:

from twikit import Client

Quick Start

import asyncio
from xkit import Client

USERNAME = "example_user"
EMAIL = "email@example.com"
PASSWORD = "password0000"

client = Client("en-US")

async def main():
    await client.login(
        auth_info_1=USERNAME,
        auth_info_2=EMAIL,
        password=PASSWORD,
        cookies_file="cookies.json",
    )

    tweets = await client.search_tweet("python", "Latest")
    for tweet in tweets:
        print(tweet.user.name, tweet.text, tweet.created_at)

asyncio.run(main())

Common Tasks

Create a tweet:

await client.create_tweet(text="Hello from XKit")

Create a tweet with media:

media_ids = [
    await client.upload_media("media1.jpg"),
    await client.upload_media("media2.jpg"),
]

await client.create_tweet(
    text="Example tweet",
    media_ids=media_ids,
)

Get user tweets:

tweets = await client.get_user_tweets("123456", "Tweets")

for tweet in tweets:
    print(tweet.text)

Send a DM:

await client.send_dm("123456789", "Hello")

Get trends:

await client.get_trends("trending")

More examples are available in examples.

Compatibility

XKit currently keeps the original twikit package as the implementation package and exposes xkit as the new public import path. This keeps old code working while giving new projects a clean package name.

Recommended for new code:

from xkit import Client

Still supported for compatibility:

from twikit import Client

Safety

This library uses Twitter/X web endpoints. Sending too many requests, automating suspicious actions, or using poor account hygiene may trigger rate limits, verification challenges, temporary locks, or account suspension.

Read ToProtectYourAccount.md before using automation-heavy workflows.

Documentation

The upstream API documentation is still useful for the inherited API surface:

XKit-specific maintenance notes:

Credits and License

XKit for Python is derived from d60/twikit, originally licensed under the MIT License.

The original copyright notice and MIT License are preserved in LICENSE.

Contributing

Bug reports and fixes are welcome in issues.

Metadata

Release files for xkit-py 2.6.3

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

Source distribution (sdist)

Source distribution for xkit-py 2.6.3
File Size Uploaded
xkit_py-2.6.3.tar.gz 43.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xkit-py 2.6.3
File Interpreter ABI Platform
xkit_py-2.6.3-py3-none-any.whl Python 3 none any Details

Total release size: 97.4 kB

Release files / xkit_py-2.6.3.tar.gz

Download URL xkit_py-2.6.3.tar.gz
Size 43.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3836ee9730457936d2e04fecf7aaf8d263eee6a2bc785391f948730c8d8ebf0a
BLAKE2b-256 checksum
How to use checksums
676a2eaead5e4d04d2f7ec31a92f7f029d247aaa7c9a0ee0d9fbc481faa56ca9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Release files / xkit_py-2.6.3-py3-none-any.whl

Download URL xkit_py-2.6.3-py3-none-any.whl
Size 54.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a051ad49a926af2f9725187827c16638a7ac53f41aaad205a837f8845b7d60b
BLAKE2b-256 checksum
How to use checksums
d00a0ed67b7deed9d9199d12c10d0c64f019ca3af33b61e8c1572ce4bdb23c94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2.6.3 This release

2 release files

2.6.2

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