Skip to main content

A fork of Tweepy adapted to work with Virtuals's enterprise Twitter endpoint

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virtuals_tweepy-0.1.4.tar.gz (89.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

virtuals_tweepy-0.1.4-py3-none-any.whl (102.6 kB view details)

Uploaded Python 3

File details

Details for the file virtuals_tweepy-0.1.4.tar.gz.

File metadata

  • Download URL: virtuals_tweepy-0.1.4.tar.gz
  • Upload date:
  • Size: 89.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for virtuals_tweepy-0.1.4.tar.gz
Algorithm Hash digest
SHA256 1dffe3bec14835a2042e8d4507b7c47ccf434f548ee1584a0d1a275760d73443
MD5 647030df9100e9f03984ae2ff342d1f3
BLAKE2b-256 11830738fa8d0cfe78c455b38ade33c3fabc510a0088760c34d02b53251c5b29

See more details on using hashes here.

File details

Details for the file virtuals_tweepy-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: virtuals_tweepy-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 102.6 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

Hashes for virtuals_tweepy-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d33e7ad5fac00e1d5924a3e7c86e2d6f9669173a790963492e41817ffb1f8821
MD5 02bb0eeea1348a56a9431a4a0c48e224
BLAKE2b-256 003460172ea272996dc1c8bba3d21f52c7af520e8120a165aa262cfe7cb27d90

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page