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.5.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.5-py3-none-any.whl (102.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: virtuals_tweepy-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 fbfc14ae545f97c2876a5a265c6d6d5d1a8d3fa40ec16c21e8e5cd38286df5a8
MD5 480848c740f1128697014f0ef234355f
BLAKE2b-256 39ed857f3f9aa1d411e34b35534c934a9689710fc09a399816d2cbb6076d655d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: virtuals_tweepy-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 464bbf8ef0767e0027edd3a6c42c1fb88204d673389389d50dbf79a592a29267
MD5 a92a20481f7b8258d25e11155c0cd26e
BLAKE2b-256 5054e3219cb9d9a6d49a252e811f4901eb096454f7cc1cbcf51a3286c40469c8

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