Skip to main content

Virtuals Protocol Tweepy: Twitter for Python!

Installation

The easiest way to install the latest version from PyPI is by using pip:

pip install virtuals-tweepy

Quickstart: Initialize Client with Virtuals Protocol's GAME Access Token

How to Get a GAME API Key

  1. Go to the Virtuals Protocol's GAME Console
  2. Sign in with your wallet.
  3. Click on "Create a New Project" to register a new project.
  4. Once your project is created, click on "Generate one now" under "API Key" to generate your API key.

How to Get GAME X Access Token (Virtuals Protocol's X Enterprise API)

  • To get the access token for this option, run the following command:

    poetry run virtuals-tweepy auth -k <GAME_API_KEY>
    

    You will see the following output:

    Waiting for authentication...
    
    Visit the following URL to authenticate:
    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
    

    After authenticating, you will receive the following message:

    Authenticated! Here's your access token:
    apx-<xxx>
    
  • With this access token, you can enjoy up to 35 calls per 5 minutes to the X API, which is significantly higher than the standard X API plan.

  • If you've obtained a GAME Twitter Access Token via the GAME authentication flow, set it as environment variables (e.g. using a .env file with python-dotenv):

    GAME_TWITTER_ACCESS_TOKEN=apx-<game-twitter-access-token>
    
  • You can now initialize the Tweepy client directly with it:

    import os
    
    from virtuals_tweepy import Client
    from dotenv import load_dotenv
    
    load_dotenv()
    
    game_twitter_access_token = os.environ.get("GAME_TWITTER_ACCESS_TOKEN")
    
    client = Client(
        game_twitter_access_token=game_twitter_access_token
    )
    

Using your own X API credentials

  • If you don't already have one, create an X (Twitter) account and navigate to the developer portal.

  • Create a project app, generate the following credentials and set them as environment variables(e.g. using a .env file with python-dotenv):

    TWITTER_BEARER_TOKEN=<twitter-bearer-token>
    TWITTER_API_KEY=<twitter-api-key>
    TWITTER_API_KEY_SECRET=<twitter-api-secret-key>
    TWITTER_ACCESS_TOKEN=<twitter-access-token>
    TWITTER_ACCESS_TOKEN_SECRET=<twitter-access-token-secret>
    
  • If you decide to use your own X API credentials, you can initialize the Tweepy client with them as follows:

    import os
    
    from virtuals_tweepy import Client
    from dotenv import load_dotenv
    
    load_dotenv()
    
    # 1. Twitter API OAuth 2.0
    bearer_token = os.environ.get("TWITTER_BEARER_TOKEN")
    
    client = Client(
      bearer_token=bearer_token
    )
    
    # 2. Twitter API OAuth 1.0a
    consumer_key = os.environ.get("TWITTER_API_KEY")
    consumer_secret = os.environ.get("TWITTER_API_KEY_SECRET")
    access_token = os.environ.get("TWITTER_ACCESS_TOKEN")
    access_token_secret = os.environ.get("TWITTER_ACCESS_TOKEN_SECRET")
    
    client = Client(
      consumer_key=consumer_key,
      consumer_secret=consumer_secret,
      access_token=access_token,
      access_token_secret=access_token_secret,
    )
    

Latest version of Python and older versions not end of life (bugfix and security) are supported.

Acknowledgments

This project is a modified version of Tweepy by Virtuals Protocol, originally created by Joshua Roesslein. Original work is Copyright (c) 2009-2023 Joshua Roesslein and is licensed under the MIT License.

Metadata

Release files for virtuals-tweepy 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for virtuals-tweepy 0.1.6
File Size Uploaded
virtuals_tweepy-0.1.6.tar.gz 89.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for virtuals-tweepy 0.1.6
File Interpreter ABI Platform
virtuals_tweepy-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 192.5 kB

Release files / virtuals_tweepy-0.1.6.tar.gz

Download URL virtuals_tweepy-0.1.6.tar.gz
Size 89.9 kB
Tags Source
SHA-256 checksum
How to use checksums
da3cacebded0e8f757e0b79d6fea4027fdea849b8083fd63cb054c2bda9edf53
BLAKE2b-256 checksum
How to use checksums
6f5be08ff370c991a084d7a4b64a17694ee546b08525686221d395fa4534a003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

Release files / virtuals_tweepy-0.1.6-py3-none-any.whl

Download URL virtuals_tweepy-0.1.6-py3-none-any.whl
Size 102.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d378d70e118596f7beaee0cac3e0f9a4022c603e36aa830f68c0111333428969
BLAKE2b-256 checksum
How to use checksums
d77a5f4f572325616ef33193c920a46ae2a5ad0d99361bea649175bcb70684b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page