Apidance SDK
A Python SDK for interacting with the Apidance API (https://apidance.pro/).
Installation
pip install apidance
Configuration
Create a .env file in your project root with your API credentials:
APIDANCE_API_KEY=your_api_key_here
X_AUTH_TOKEN=your_x_auth_token_here # Required for reply/like actions
Get your API key from https://apidance.pro
You can find your X_AUTH_TOKEN in your browser cookies when logged into x.com:
- Open x.com and log in
- Open browser developer tools (F12 or right-click -> Inspect)
- Go to Application/Storage -> Cookies -> x.com
- Find and copy the value of
auth_token
Or provide the credentials directly when initializing the client:
client = TwitterClient(
api_key="your_api_key_here",
auth_token="your_auth_token_here" # Required for reply/like actions
)
Usage
Check out the examples
from apidance import TwitterClient
# Initialize the client
client = TwitterClient()
# Search posts (one cursor-paginated page)
response = client.search(query="python", limit=20)
for tweet in response.data:
print(tweet.author.username, tweet.text, tweet.metrics.like_count)
# Fetch the next page, when available
if response.meta.next_cursor:
next_page = client.search(query="python", cursor=response.meta.next_cursor)
# Get user information
user = client.get_user_by_screen_name("example")
users = client.get_following(user_id=user["id"])
# Get tweets from a list
list_tweets = client.get_list_latest_tweets(
list_id="your_list_id",
)
# Reply to a tweet
client.create_tweet(
text="Your reply text",
reply_to_tweet_id="tweet_id_to_reply_to",
)
# Like a tweet
client.favorite_tweet(tweet_id="tweet_id_to_like")
MCP server
FillSet config file
{
"mcpServers": {
"apidance": {
"command": "/path/to/uv",
"args": [
"--directory",
"/path/to/apidance-sdk",
"run",
"mcp_server.py"
]
}
}
}
Features
- Search Twitter timeline with various filters (Latest, Top, People, Photos, Videos)
- Get detailed user information by screen name
- Fetch tweets from Twitter lists
- Search Following
- Reply to tweets (requires auth_token)
- Like tweets (requires auth_token)
- Create tweets and reply to existing tweets
- Create note tweets (long rich text tweet, requires Premium+)
- Host as mcp server
Search response (v2)
TwitterClient.search() and the MCP search_tweets tool return a structured
response with data and meta. Each post includes its author, ISO 8601
timestamp, metrics, URLs, mentions, media, reply/quote/repost references, and
language/source fields. meta.next_cursor is the value to supply to the next
search request.
Models
The SDK provides two main data models:
Tweet: Represents a Twitter post with all its metadataUser: Contains detailed user information including profile data, stats, and verification status
License
MIT License
Metadata
Release files for apidance 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| apidance-0.8.0.tar.gz | 21.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apidance-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.2 kB
Release files / apidance-0.8.0.tar.gz
| Download URL | apidance-0.8.0.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d5c26f8776d6d5fa8ae72e8fbe26f60cf0ec6f5d1e0558d556efe9e67688a7c
|
|
BLAKE2b-256 checksum How to use checksums |
834a6a56745a6c4d0e4429b188036588a4517a53bcf998ef77d7d8f8ced6b806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / apidance-0.8.0-py3-none-any.whl
| Download URL | apidance-0.8.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
545e3d3123ad823bba3e9d5ccc09caa5377e32daca430e97b3c2109ee08ac491
|
|
BLAKE2b-256 checksum How to use checksums |
986fe813b7b26b955da45dfa15494e2bcc7c03578cc7c093ab056431b1726eab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|