Skip to main content

OSoMe Twitter library for academic researchers

Project description

PyPI version v2

Introduction

The OSoMeTweet project intends to provide a set of tools to help researchers work with the V2 API of Twitter. The Wiki will work as an unofficial archive of knowledge people gather through the process.

Installation

Install the PyPI version

pip install osometweet

Warning 1: the package is still in development, so the functionalities are very limited and the robustness is low.

Warning 2: we will try to keep the interface of the package consistent, but there maybe drastic changes in the future.

Use the newest features & local development

The PyPI version is behind the GitHub version. To take advantage of the newest features and functionalities, you can install the GitHub version locally.

To do so, clone this project, go to the source directory, type the following command to install the package locally:

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

How to seek helps and contribute

OSoMeTweet will be a community project. If you encounter bugs, please create Issues. If you want to contribute to the project, you are welcome to create Pull Requests.

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 without these ids
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'}
]

We offer examples for working with different endpoints.

For detailed instructions, check out our wiki.

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

osometweet-0.3.tar.gz (11.5 kB view hashes)

Uploaded Source

Built Distribution

osometweet-0.3-py3-none-any.whl (11.4 kB view hashes)

Uploaded Python 3

Supported by

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