A Python API for Truthy BotOrNot.
Behind the scenes, this uses the BotOrNot's HTTP endpoint as illustrated in this notebook.
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.
From your command shell, run
pip install botornot
then in a Python shell or script, enter something like this:
import botornot
twitter_app_auth = {
'consumer_key': 'xxxxxxxx',
'consumer_secret': 'xxxxxxxxxx',
'access_token': 'xxxxxxxxx',
'access_token_secret': 'xxxxxxxxxxx',
}
bon = botornot.BotOrNot(**twitter_app_auth)
# Check a single account
result = bon.check_account('@clayadavis')
# Check a sequence of accounts
accounts = ['@clayadavis', '@onurvarol', '@jabawack']
results = list(bon.check_accounts_in(accounts))
Result:
{
"score": 0.37,
"meta": {"screen_name": "clayadavis", "user_id": "1548959833"},
"categories": {
"content_classification": 0.27,
"friend_classification": 0.15,
"network_classification": 0.17,
"sentiment_classification": 0.25,
"temporal_classification": 0.43,
"user_classification": 0.36
}
}
- Clone this repository and navigate to it with your terminal of choice.
python setup.py install
Both of these dependencies are available via pip
, so you can install both at once with
pip install requests tweepy
In order to access Twitter's API, one needs to have/create a Twitter app. Once you've created an app, the authentication info can be found in the "Keys and Access Tokens" tab of the app's properties: