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.3.tar.gz (43.3 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.3-py3-none-any.whl (54.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xkit_py-2.6.3.tar.gz
  • Upload date:
  • Size: 43.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xkit_py-2.6.3.tar.gz
Algorithm Hash digest
SHA256 3836ee9730457936d2e04fecf7aaf8d263eee6a2bc785391f948730c8d8ebf0a
MD5 ebb76d9ba63cc54d5891277d317647a2
BLAKE2b-256 676a2eaead5e4d04d2f7ec31a92f7f029d247aaa7c9a0ee0d9fbc481faa56ca9

See more details on using hashes here.

Provenance

The following attestation bundles were made for xkit_py-2.6.3.tar.gz:

Publisher: publish.yml on inorilzy/xkit-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: xkit_py-2.6.3-py3-none-any.whl
  • Upload date:
  • Size: 54.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for xkit_py-2.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a051ad49a926af2f9725187827c16638a7ac53f41aaad205a837f8845b7d60b
MD5 a1578d8c19861e653fb0a0a361599a80
BLAKE2b-256 d00a0ed67b7deed9d9199d12c10d0c64f019ca3af33b61e8c1572ce4bdb23c94

See more details on using hashes here.

Provenance

The following attestation bundles were made for xkit_py-2.6.3-py3-none-any.whl:

Publisher: publish.yml on inorilzy/xkit-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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