Skip to content

Commit 3c764e7

Browse files
authored
Merge branch 'main' into feat/acp
2 parents f2545e4 + a9e2728 commit 3c764e7

File tree

7 files changed

+248
-167
lines changed

7 files changed

+248
-167
lines changed

plugins/twitter/README.md

Lines changed: 84 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,115 @@
11
# Twitter Plugin for GAME SDK
22

3-
The Twitter plugin is a lightweight wrapper over commonly-used twitter API calls. It can be used as a executable on its own or by combining multiple of these into an executable.
3+
The **Twitter Plugin** provides a lightweight interface for integrating Twitter (X) functionality into your GAME SDK agents. Built on top of [`virtuals_tweepy`](https://pypi.org/project/virtuals-tweepy/) by the Virtuals team — a maintained fork of [`Tweepy`](https://pypi.org/project/tweepy/)) — this plugin lets you easily post tweets, fetch data, and execute workflows through agent logic.
4+
5+
## 📜 GAME X API Usage Terms & Rules
6+
By using our GAME API, you agree to the [Terms of Use](https://virtualsprotocol.notion.site/Terms-of-Use-2152d2a429e980f09a74c85c0a5974c4?source=copy_link) and [GAME X API Terms](https://virtualsprotocol.notion.site/Agents-on-X-Rulebook-1972d2a429e980ddaa85da3c903afade?pvs=74).
7+
8+
## 🚀 API Access Tiers
9+
Virtuals sponsors the community with a **Twitter Enterprise API access plan**, using OAuth 2.0 with PKCE. This provides:
10+
11+
## 🚀 API Access Tiers
12+
### Tier 1 — Default
13+
- Higher rate limits: **50 calls / 5 minutes**
14+
- Smoother onboarding
15+
- Free usage via your `GAME_API_KEY`
16+
17+
### Tier 2 — Elevated
18+
- Even higher rate limits
19+
- Requires approval from the Virtuals team. Request access via Discord → @virtualsio
20+
21+
---
22+
Use it standalone or compose multiple Twitter actions as part of a larger agent job.
423

524
## Installation
625

7-
From this directory (`twitter`), run the installation:
26+
You can install the plugin using either `poetry` or `pip`:
827

928
```bash
29+
# Using Poetry (from the plugin directory)
1030
poetry install
1131
```
32+
or
33+
```bash
34+
# Using pip (recommended for integration projects)
35+
pip install twitter_plugin_gamesdk
36+
```
1237

13-
## Usage
38+
---
1439

15-
The Twitter plugin can be initialized in one of two ways:
40+
## Authentication Methods
41+
Virtuals sponsors the community with a **Twitter Enterprise API access plan**, using OAuth 2.0 with PKCE. This provides:
1642

17-
1. Using GAME's X enterprise API credentials (higher rate limits)
43+
- Higher rate limits: **35 calls / 5 minutes**
44+
- Smoother onboarding
45+
- Free usage via your `GAME_API_KEY`
1846

19-
- To get the access token for this option, run the following command:
47+
#### 1. Get Your Access Token
2048

21-
```bash
22-
poetry run twitter-plugin-gamesdk auth -k <GAME_API_KEY>
23-
```
49+
Run the following command to authenticate using your `GAME_API_KEY`:
2450

25-
You will see the following output:
51+
```bash
52+
poetry run twitter-plugin-gamesdk auth -k <GAME_API_KEY>
53+
```
2654

27-
```bash
28-
Waiting for authentication...
55+
This will prompt:
2956

30-
Visit the following URL to authenticate:
31-
https://x.com/i/oauth2/authorize?response_type=code&client_id=VVdyZ0t4WFFRMjBlMzVaczZyMzU6MTpjaQ&redirect_uri=http%3A%2F%2Flocalhost%3A8714%2Fcallback&state=866c82c0-e3f6-444e-a2de-e58bcc95f08b&code_challenge=K47t-0Mcl8B99ufyqmwJYZFB56fiXiZf7f3euQ4H2_0&code_challenge_method=s256&scope=tweet.read%20tweet.write%20users.read%20offline.access
32-
```
57+
```bash
58+
Waiting for authentication...
3359

34-
After authenticating, you will receive the following message:
60+
Visit the following URL to authenticate:
61+
https://x.com/i/oauth2/authorize?...
3562

36-
```bash
37-
Authenticated! Here's your access token:
38-
apx-<xxx>
39-
```
63+
Authenticated! Here's your access token:
64+
apx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
65+
```
66+
67+
#### 2. Store Your Access Token
4068
41-
- Set the access token as an environment variable called `GAME_TWITTER_ACCESS_TOKEN` (e.g. using a `.bashrc` or a `.zshrc` file).
42-
- Import and initialize the plugin to use in your worker:
69+
We recommend storing environment variables in a `.env` file:
4370
44-
```python
45-
import os
46-
from twitter_plugin_gamesdk.twitter_plugin import TwitterPlugin
71+
```
72+
# .env
73+
74+
GAME_TWITTER_ACCESS_TOKEN=apx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
75+
```
4776
48-
# Define your options with the necessary credentials
49-
options = {
50-
"credentials": {
51-
"gameTwitterAccessToken": os.environ.get("GAME_TWITTER_ACCESS_TOKEN")
52-
},
53-
}
54-
# Initialize the TwitterPlugin with your options
55-
twitter_plugin = TwitterPlugin(options)
77+
Then, use `load_dotenv()` to load them:
5678
57-
# Post a tweet
58-
post_tweet_fn = twitter_plugin.get_function('post_tweet')
59-
post_tweet_fn("Hello world!")
60-
```
79+
```python
80+
import os
81+
from dotenv import load_dotenv
82+
from twitter_plugin_gamesdk.twitter_plugin import TwitterPlugin
6183
62-
2. Using your own X API credentials
84+
load_dotenv()
85+
86+
options = {
87+
"credentials": {
88+
"game_twitter_access_token": os.environ.get("GAME_TWITTER_ACCESS_TOKEN")
89+
}
90+
}
91+
92+
twitter_plugin = TwitterPlugin(options)
93+
client = twitter_plugin.twitter_client
94+
95+
client.create_tweet(text="Tweeting with GAME Access Token!")
96+
```
97+
---
6398
64-
- If you don't already have one, create a X (twitter) account and navigate to the [developer portal](https://developer.x.com/en/portal/dashboard).
65-
- Create a project app, generate the following credentials and set them as environment variables (e.g. using a `.bashrc` or a `.zshrc` file):
66-
- `TWITTER_BEARER_TOKEN`
67-
- `TWITTER_API_KEY`
68-
- `TWITTER_API_SECRET_KEY`
69-
- `TWITTER_ACCESS_TOKEN`
70-
- `TWITTER_ACCESS_TOKEN_SECRET`
71-
- Import and initialize the plugin to use in your worker:
99+
## Examples
72100
73-
```python
74-
import os
75-
from twitter_plugin_gamesdk.twitter_plugin import TwitterPlugin
101+
Explore the [`examples/`](./examples) directory for sample scripts demonstrating how to:
76102
77-
# Define your options with the necessary credentials
78-
options = {
79-
"credentials": {
80-
"bearerToken": os.environ.get("TWITTER_BEARER_TOKEN"),
81-
"apiKey": os.environ.get("TWITTER_API_KEY"),
82-
"apiSecretKey": os.environ.get("TWITTER_API_SECRET_KEY"),
83-
"accessToken": os.environ.get("TWITTER_ACCESS_TOKEN"),
84-
"accessTokenSecret": os.environ.get("TWITTER_ACCESS_TOKEN_SECRET"),
85-
},
86-
}
87-
# Initialize the TwitterPlugin with your options
88-
twitter_plugin = TwitterPlugin(options)
103+
- Post tweets
104+
- Reply to mentions
105+
- Quote tweets
106+
- Fetch user timelines
107+
- And more!
89108
90-
# Post a tweet
91-
post_tweet_fn = twitter_plugin.twitter_client.create_tweet
92-
post_tweet_fn(text="Hello world! This is a test tweet from the Twitter Plugin!")
93-
```
109+
---
94110
95-
For detailed documentation on each function's parameters and usage, please refer to the [Tweepy Client Documentation](https://docs.tweepy.org/en/stable/client.html).
111+
## API Reference
96112
97-
Example usage:
113+
This plugin wraps [`virtuals_tweepy`](https://pypi.org/project/virtuals-tweepy/), which is API-compatible with [Tweepy’s client interface](https://docs.tweepy.org/en/stable/client.html). Refer to their docs for supported methods and parameters.
98114
99-
You can refer to the example files in the `examples` directory for more examples on how to call the twitter functions.
115+
---
-14.6 KB
Binary file not shown.
95.4 KB
Loading

0 commit comments

Comments
 (0)