OSoMe Twitter library for academic researchers
Project description
Introduction
The OSoMeTweet project intends to provide a set of tools to help researchers work with Twitter's V2 API.
The Wiki includes a detailed documentation of how to use all methods. Also, we will use the wiki to store knowledge gathered by those who are building this package.
Installation
Install the PyPI version
pip install osometweet
Warning 1: The package is still in development, so not all endpoints are included and those which are included may not be 100% robust. Please see the list of issues for known problems.
Warning 2: We will try to keep the interface of the package consistent, but there may be drastic changes in the future.
Use the newest features & local development
The PyPI version may be behind the GitHub version. To ensure that you are using the latest features and functionalities, you can install the GitHub version locally.
To do so, clone this project, go to the source directory, and run pip install -e .
If you want to do this with git
it should look something like the below, run from your command line:
git clone https://github.com/osome-iu/osometweet.git
cd ./osometweet
pip install -e .
Requirements
python>=3.5
requests>=2.24.0
requests_oauthlib>=1.3.0
Tests
Go to tests
directory and run:
python tests.py
Note: you will need to have the following environment variables set in order for the tests to work properly.
- TWITTER_API_KEY
- TWITTER_API_KEY_SECRET
- TWITTER_ACCESS_TOKEN
- TWITTER_ACCESS_TOKEN_SECRET
- TWITTER_BEARER_TOKEN
If you're not sure what these are, check out this page to learn how Twitter authentication works.
How to seek help and contribute
OSoMeTweet will be a community project and your help is welcome!
See How to contribute to the OsoMeTweet package for more details on how to contribute.
Quick start
Here is an example of how to use our package to pull user information:
import osometweet
# Initialize the OSoMeTweet object
bearer_token = "YOUR_TWITTER_BEARER_TOKEN"
oauth2 = osometweet.OAuth2(bearer_token=bearer_token)
ot = osometweet.OsomeTweet(oauth2)
# Set some test IDs (these are Twitter's own accounts)
ids2find = ["2244994945", "6253282"]
# Call the function with these ids as input
response = ot.user_lookup_ids(user_ids=ids2find)
print(response["data"])
which returns a list of dictionaries, where each dictionary contains the requested information for an individual user.
[
{'id': '2244994945', 'name': 'Twitter Dev', 'username': 'TwitterDev'},
{'id': '6253282', 'name': 'Twitter API', 'username': 'TwitterAPI'}
]
Learn how to use the package
Documentation on how to use all package methods are located in the Wiki.
Start here before using the example scripts!
Learn about Twitter V2
We have documented (and will continue to document) information about Twitter's V2 API that we deem is valuable. For example:
- Details on Twitter's new fields/expansions parameters
- Available Endpoints
- HTTP Status Codes and Errors
- Academic Track Benefits and Details
Example Scripts
We offer example scripts for working with different endpoints. We recommend that you read and understand the methods by reading the relevant package Wiki pages prior to using these scripts.
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
Built Distribution
File details
Details for the file osometweet-0.4.tar.gz
.
File metadata
- Download URL: osometweet-0.4.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76a981c5eb6bdf4300a42df470aa209afe013b8a6ea20d27d8c40c5574cac7e2 |
|
MD5 | 782342de1b1e7a6cd017a0f66e1bfb49 |
|
BLAKE2b-256 | 37fc1f197dfefaa62c9388c5e8c7520012cddb9513d299afad1eb6a513b99568 |
File details
Details for the file osometweet-0.4-py3-none-any.whl
.
File metadata
- Download URL: osometweet-0.4-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.5.0.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19ebc738a6ba2425d3091b09d9ae708e977814e15fafdf3090c2ec25901f107e |
|
MD5 | 9065cf832cb1522201bc30da05f32142 |
|
BLAKE2b-256 | ec7fe82e03b7750f303f0a0703e097480b7b1081e2cecc87de6b0256baedb826 |