twitter-api-client  by trevorhobenshield

Python SDK for X/Twitter API access, scraping, and automation

created 2 years ago
1,828 stars

Top 24.1% on sourcepulse

GitHubView on GitHub
Project Summary

This Python library provides a comprehensive client for interacting with the X (formerly Twitter) API, including v1, v2, and GraphQL endpoints. It is designed for developers and power users who need to automate tasks, scrape data, or manage their X accounts programmatically. The library offers functionalities for account management, data scraping, search, and even specialized features like live audio capture from Spaces.

How It Works

The client is structured into several modules: Account for performing actions like tweeting, replying, liking, and managing profiles; Scraper for fetching various types of data such as user profiles, tweets, media, and relationships; and Search for executing complex queries. It leverages session management via cookies or credentials, with a recommendation to use cookies due to potential instability with username/password logins. The library also includes utilities for handling pagination and offers batching for certain endpoints (e.g., users_by_ids, tweets_by_ids) to improve efficiency and adhere to rate limits.

Quick Start & Requirements

  • Install via pip: pip install twitter-api-client -U
  • Requires Python 3.7+
  • Authentication can be done via email/username/password or by providing cookies (JSON file or dictionary).
  • For automated solvers (email verification), proton-api-client is required.

Highlighted Details

  • Supports X v1, v2, and GraphQL APIs.
  • Offers efficient batch queries for scraping (e.g., tweets_by_ids with ~220 items per request).
  • Includes functionality for capturing live audio and transcripts from X Spaces.
  • Supports automated solvers for Proton Mail email verification to streamline account setup.
  • Provides detailed example API responses for common data structures.

Maintenance & Community

The repository is maintained by trevorhobenshield. Further community or maintenance details are not explicitly provided in the README.

Licensing & Compatibility

The README does not specify a license. Users should verify licensing before commercial use or integration into closed-source projects.

Limitations & Caveats

The README notes that login via username/password is unstable as of Fall 2023, recommending cookie-based authentication. Some API endpoints might be subject to X's rate limits and terms of service.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
61 stars in the last 90 days

Explore Similar Projects

Starred by Adam Wolff Adam Wolff(Claude Code Core; MTS at Anthropic), Samuel Colvin Samuel Colvin(Author of Pydantic, Pydantic Logfire, PydanticAI), and
3 more.

anthropic-sdk-python by anthropics

0.7%
2k
Python SDK for Anthropic's REST API
created 2 years ago
updated 22 hours ago
Feedback? Help us improve.