Skip to main content

XKit for Python: a maintained Twitter/X web API client with no API key required.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xkit_py-2.6.2.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xkit_py-2.6.2-py3-none-any.whl (54.5 kB view details)

Uploaded Python 3

File details

Details for the file xkit_py-2.6.2.tar.gz.

File metadata

  • Download URL: xkit_py-2.6.2.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for xkit_py-2.6.2.tar.gz
Algorithm Hash digest
SHA256 0a99c51f0d8f3334a21381f8c8935d4494cd4297d9a287d336140cb63b9848ee
MD5 f5c643eaaafd9d860f914c1dcf460c83
BLAKE2b-256 18a3a3bf8adbefc8ff374c804277ca12bd0df7aa3a9990b737bcb0de5420ac94

See more details on using hashes here.

File details

Details for the file xkit_py-2.6.2-py3-none-any.whl.

File metadata

  • Download URL: xkit_py-2.6.2-py3-none-any.whl
  • Upload date:
  • Size: 54.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for xkit_py-2.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 99f195605367c5ab68525517ffe8fdde5f78b9fa12221f89ba32a7e9cb2ac29d
MD5 1489b274444186a396536e2e42270244
BLAKE2b-256 70d009d2fba18c0d9ed3b00344f07f183cede3d4c40a75aebcf4efcd655e177c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page