Twitter Plugin for Python SDK for GAME by Virtuals
Project description
Twitter Plugin for GAME SDK
The Twitter Plugin provides a lightweight interface for integrating Twitter (X) functionality into your GAME SDK agents. Built on top of virtuals_tweepy by the Virtuals team — a maintained fork of Tweepy) — this plugin lets you easily post tweets, fetch data, and execute workflows through agent logic.
Use it standalone or compose multiple Twitter actions as part of a larger agent job.
Installation
You can install the plugin using either poetry or pip:
# Using Poetry (from the plugin directory)
poetry install
or
# Using pip (recommended for integration projects)
pip install twitter_plugin_gamesdk
Authentication Methods
We support two primary ways to authenticate:
1. GAME's Sponsored X Enterprise Access Token (Recommended)
Virtuals sponsors the community with a Twitter Enterprise API access plan, using OAuth 2.0 with PKCE. This provides:
- Higher rate limits: 35 calls / 5 minutes
- Smoother onboarding
- Free usage via your
GAME_API_KEY
a. Get Your Access Token
Run the following command to authenticate using your GAME_API_KEY:
poetry run twitter-plugin-gamesdk auth -k <GAME_API_KEY>
This will prompt:
Waiting for authentication...
Visit the following URL to authenticate:
https://x.com/i/oauth2/authorize?...
Authenticated! Here's your access token:
apx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b. Store Your Access Token
We recommend storing environment variables in a .env file:
# .env
GAME_TWITTER_ACCESS_TOKEN=apx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Then, use load_dotenv() to load them:
import os
from dotenv import load_dotenv
from twitter_plugin_gamesdk.twitter_plugin import TwitterPlugin
load_dotenv()
options = {
"credentials": {
"game_twitter_access_token": os.environ.get("GAME_TWITTER_ACCESS_TOKEN")
}
}
twitter_plugin = TwitterPlugin(options)
client = twitter_plugin.twitter_client
client.create_tweet(text="Tweeting with GAME Access Token!")
2. Use Your Own Twitter Developer Credentials
Use this option if you need access to Twitter endpoints requiring a different auth level (e.g., OAuth 1.0a User Context or OAuth 2.0 App Only).
See X API Auth Mapping to determine which auth level is required for specific endpoints.
a. Get Your Developer Credentials
- Sign in to the Twitter Developer Portal.
- Create a project and app.
- Generate the following keys and store them in your
.envfile:
# .env
TWITTER_API_KEY=...
TWITTER_API_SECRET_KEY=...
TWITTER_ACCESS_TOKEN=...
TWITTER_ACCESS_TOKEN_SECRET=...
b. Initialize the Plugin
import os
from dotenv import load_dotenv
from twitter_plugin_gamesdk.twitter_plugin import TwitterPlugin
load_dotenv()
options = {
"credentials": {
"api_key": os.environ.get("TWITTER_API_KEY"),
"api_key_secret": os.environ.get("TWITTER_API_SECRET_KEY"),
"access_token": os.environ.get("TWITTER_ACCESS_TOKEN"),
"access_token_secret": os.environ.get("TWITTER_ACCESS_TOKEN_SECRET"),
}
}
twitter_plugin = TwitterPlugin(options)
client = twitter_plugin.twitter_client
client.create_tweet(text="Tweeting with personal developer credentials!")
Examples
Explore the examples/ directory for sample scripts demonstrating how to:
- Post tweets
- Reply to mentions
- Quote tweets
- Fetch user timelines
- And more!
API Reference
This plugin wraps virtuals_tweepy, which is API-compatible with Tweepy’s client interface. Refer to their docs for supported methods and parameters.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twitter_plugin_gamesdk-0.2.9.tar.gz.
File metadata
- Download URL: twitter_plugin_gamesdk-0.2.9.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dbe11b0dac394ec74ae637101284b142746587c474610eb546525cdc92ba8d3
|
|
| MD5 |
7d47407b4759969f235a8c7f989f2914
|
|
| BLAKE2b-256 |
f9a52667ed340577e6a0106d5534dba96a4f3644d45e234b849ffcdc73015832
|
File details
Details for the file twitter_plugin_gamesdk-0.2.9-py3-none-any.whl.
File metadata
- Download URL: twitter_plugin_gamesdk-0.2.9-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0719f9a6fe64c8d73dcfe7d190935ee23abba288df7e95af48b31b570c32fe4c
|
|
| MD5 |
963de90e281b3d604a4a86f47bee51fe
|
|
| BLAKE2b-256 |
ca015dff9f7a2e1c64717abe38adaa9286b02d6d95c12672c127fb1850b8b037
|