osome-iu / botometer-python

A Python API for Botometer by OSoMe
https://botometer.osome.iu.edu
MIT License
371 stars 59 forks source link

PyPI version

Botometer X Python API

A Python API for Botometer X by OSoMe. Previously known as botornot-python.

Behind the scenes, this uses the Botometer's HTTP endpoint, available via RapidAPI.

RapidAPI usage/account related questions should be posted on RapidAPI discussion.

[Change Note/Announcement]

June, 2024

We are releasing a new API endpoint for Botometer X.

Unlike the original Botometer that fetched data from Twitter and calculated bot scores on the fly, Botometer X is in archival mode and relies on pre-calculated scores based on historical data collected before June 2023. The API endpoint allows users to fetch scores in bulk using a list of user ids or screen names, without the need of a Twitter/X's developer account.

For details of Botometer X, please refer to the FQA.

Help

You probably want to have a look at Troubleshooting & FAQ in the wiki. Please feel free to suggest and/or contribute improvements to that page.

Prior to Utilizing Botometer

To begin using Botometer X, you must follow the steps below before running any code:

  1. Create a free RapidAPI account.
  2. Subscribe to Botometer Pro on RapidApi by selecting a plan.

    There is a completely free version (which does not require any credit card information) for testing purposes.

  3. Ensure Botometer Pro's dependencies are already installed.

    See the Dependencies section for details.

Quickstart

From your command shell, run

pip install botometer

Botometer X

To access the Botometer X endpoint, enter something like this in a Python shell or script:

import botometer

rapidapi_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

bomx = botometer.BotometerX(rapidapi_key=rapidapi_key)
# Check accounts by usernames, note that @ is optional
bomx.get_botscores_in_batch(usernames=['@OSoMe_IU', 'botometer'])

# Check accounts by ids
bomx.get_botscores_in_batch(user_ids=[2451308594, 187521608])

# Check accounts by both usernames and ids
bomx.get_botscores_in_batch(usernames=['@OSoMe_IU'], user_ids=[2451308594])

The queries will return results like those below:

[
    {
        "bot_score": 0.09,
        "timestamp": "Sat, 27 May 2023 23:57:16 GMT",
        "user_id": "2451308594",
        "username": "Botometer"
    },
    {
        "bot_score": 0.21,
        "timestamp": "Thu, 25 May 2023 22:54:53 GMT",
        "user_id": "187521608",
        "username": "OSoMe_IU"
    }
]

The response will be a list of JSON objects. Meanings of the elements in the object:

For more information on the API, consult the API Overview on RapidAPI.

Installation instructions

This package is on PyPI so you can install it with pip:

$ pip install botometer

Dependencies

Python dependencies

The dependency should be installed automatically with pip.

References