Skip to main content

Installation

pip install xpoz
Requires Python 3.10+.

Get an Access Key

Sign up and get your token at xpoz.ai/get-token.

Create a Client

The Python SDK provides both synchronous and asynchronous clients.
from xpoz import XpozClient

# Pass access key directly
client = XpozClient("your-api-key")

# Or use the XPOZ_API_KEY environment variable
client = XpozClient()

Configuration Options

ParameterTypeDefaultDescription
api_keystros.environ["XPOZ_API_KEY"]Access key for authentication
server_urlstrhttps://mcp.xpoz.ai/mcpMCP server URL
timeoutint300Operation timeout in seconds
client = XpozClient(
    "your-api-key",
    server_url="https://mcp.xpoz.ai/mcp",
    timeout=600,  # 10 minutes
)

Your First Call

from xpoz import XpozClient

client = XpozClient("your-api-key")

# Get a Twitter user profile
user = client.twitter.get_user("elonmusk")
print(f"{user.name}{user.followers_count:,} followers")

# Search for posts
results = client.twitter.search_posts("artificial intelligence", start_date="2025-01-01")
for tweet in results.data:
    print(tweet.text, tweet.like_count)

client.close()

Context Managers

Use context managers to automatically close the client when done.
with XpozClient("your-api-key") as client:
    user = client.twitter.get_user("elonmusk")
    # client.close() is called automatically

Field Selection

All methods accept a fields parameter. Use snake_case field names — the SDK automatically converts to camelCase for the API.
results = client.twitter.search_posts(
    "AI",
    fields=["id", "text", "like_count", "retweet_count", "created_at_date"],
)

user = client.twitter.get_user(
    "elonmusk",
    fields=["id", "username", "name", "followers_count", "description"],
)
Requesting fewer fields significantly improves response time and reduces memory usage, especially for large result sets.

Query Syntax

The query parameter on search_posts, get_users_by_keywords, and similar methods supports Lucene-style full-text search:
# Exact phrase
client.twitter.search_posts('"machine learning"')

# Boolean operators
client.twitter.search_posts('"deep learning" AND python')
client.twitter.search_posts("tensorflow OR pytorch")
client.twitter.search_posts("climate AND policy")

# Grouping
client.twitter.search_posts('(AI OR "artificial intelligence") AND ethics')

# Combined with filters
results = client.twitter.search_posts(
    '("machine learning" OR "deep learning") AND python',
    start_date="2025-01-01",
    language="en",
)
Do not use from:, lang:, since:, or until: in the query string. Use the dedicated parameters (author_username, language, start_date, end_date) instead.

Environment Variables

VariableDescriptionDefault
XPOZ_API_KEYAccess key for authentication
XPOZ_SERVER_URLMCP server URLhttps://mcp.xpoz.ai/mcp

Next Steps