{"id":24847,"library":"xdk","title":"X API Python SDK (xdk)","description":"The official Python SDK for the X (formerly Twitter) API, currently at v0.9.0. Provides asynchronous and synchronous clients, OAuth 2.0 support, and wrappers for endpoints like tweets, users, media, and direct messages. Active development with monthly releases.","status":"active","version":"0.9.0","language":"python","source_language":"en","source_url":"https://github.com/xdevplatform/xdk-python","tags":["x","twitter","api","sdk","oauth"],"install":[{"cmd":"pip install xdk","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Used for synchronous HTTP requests (deprecated in favor of httpx).","package":"requests","optional":true},{"reason":"Primary HTTP client for both sync and async operations.","package":"httpx","optional":false}],"imports":[{"note":"XClient is a top-level export; avoid deep internal paths.","wrong":"from xdk.client import XClient","symbol":"XClient","correct":"from xdk import XClient"},{"note":"","wrong":"","symbol":"AsyncXClient","correct":"from xdk import AsyncXClient"},{"note":"OAuth2Bearer is in the auth submodule, not top-level.","wrong":"from xdk import OAuth2Bearer","symbol":"OAuth2Bearer","correct":"from xdk.auth import OAuth2Bearer"}],"quickstart":{"code":"import os\nfrom xdk import XClient\nfrom xdk.auth import OAuth2Bearer\n\nbearer_token = os.environ.get('X_BEARER_TOKEN', '')\n\nauth = OAuth2Bearer(token=bearer_token)\nclient = XClient(auth=auth)\n\n# Get a user's info\nuser = client.users.get_me()\nprint(user)\n","lang":"python","description":"Initialize a synchronous client with OAuth 2.0 Bearer token and fetch the authenticated user's info."},"warnings":[{"fix":"Use `from xdk import XClient` instead.","message":"In v0.5.0, the client class was renamed from `X` to `XClient`. Old code using `from xdk import X` will break.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Create an `OAuth2Bearer` object and pass it as `auth=OAuth2Bearer(token=...)`.","message":"In v0.8.0, the `auth` parameter changed from accepting a tuple to requiring an Auth object. Passing `(bearer_token,)` no longer works.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Ensure `httpx` is installed and do not force `use_requests=True`.","message":"The `requests`-based fallback HTTP client is deprecated and will be removed in v1.0.0. Use `httpx` (the default).","severity":"deprecated","affected_versions":">=0.4.0"},{"fix":"Always use `await client.some_method()` when using `AsyncXClient`.","message":"Async client methods must be awaited. Failing to `await` a coroutine will yield a warning or error.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change import to `from xdk import XClient`.","cause":"The class was renamed from `X` to `XClient` in v0.5.0.","error":"ImportError: cannot import name 'X' from 'xdk'"},{"fix":"Use `from xdk.auth import OAuth2Bearer` and pass `auth=OAuth2Bearer(token=...)`.","cause":"Prior to v0.8.0, you could pass `bearer_token` directly to the client constructor. This was removed.","error":"TypeError: __init__() got an unexpected keyword argument 'bearer_token'"},{"fix":"Use top-level import `from xdk import XClient`.","cause":"The internal module structure changed; direct imports from `xdk.client` are no longer supported.","error":"AttributeError: module 'xdk' has no attribute 'client'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}