X (Twitter) API Integration for Openclaw

A zero-dependency Python CLI tool for interacting with X (Twitter) API v2 to manage profiles, timelines, search, and posting.

odrobnik
v1.0.0
Mar 8, 2026
0
950
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install x-api-v2

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install x-api-v2 using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is X (Twitter) API Integration?

The X (Twitter) API v2 skill provides a robust interface for Openclaw Skills to interact with one of the world's largest real-time data sources. Built using the Python standard library to ensure zero external dependencies, this skill allows AI agents to fetch user metadata, extract complex conversation threads, and perform advanced searches using X's powerful operator syntax. It effectively bridges the gap between raw social data and actionable insights for your automated workflows.

Beyond simple data retrieval, this Openclaw Skills extension supports user-authenticated actions via OAuth 2.0. This enables advanced capabilities such as managing bookmarks, retrieving liked tweets, and posting new content directly to a user's feed. Whether you are conducting sentiment analysis or automating brand presence, this skill offers the technical depth required for professional-grade social media integrations within an agentic environment.

X (Twitter) API Integration Use Cases

  • Market Research: Monitor brand mentions and industry trends over the last 7 days using the advanced search command.
  • Knowledge Management: Automatically retrieve and archive bookmarked tweets into your local databases or notes.
  • Thread Extraction: Pull full conversation threads by a single author to summarize long-form social discussions or technical tutorials.
  • Automated Engagement: Post updates or announcements directly to X as part of an automated deployment or marketing workflow triggered by your agent.

How X (Twitter) API Integration Works

  1. The AI agent invokes the Python script with specific commands such as search, timeline, or post.
  2. For public data, the skill uses a Bearer token to authenticate requests against the X API v2 endpoints.
  3. For private or write-access actions (like posting), the skill initiates an OAuth 2.0 flow to obtain the necessary user-context permissions.
  4. Data is fetched using Python's native urllib and json modules to maintain high performance and environment portability.
  5. The skill processes the raw JSON response and formats it into clean, human-readable text for the Openclaw Skills agent to consume and analyze.

X (Twitter) API Integration Setup

To integrate this into your Openclaw Skills environment, ensure you have Python 3 installed. You will need a Developer account on the X portal to obtain a Bearer Token and OAuth 2.0 Client ID/Secret.

# Initialize authentication for user-context features (bookmarks, posting)
python3 scripts/x.py auth

# Example: Fetch a user profile to verify your credentials
python3 scripts/x.py user [username]

X (Twitter) API Integration Data Schema & Taxonomy

The skill outputs structured text designed for easy parsing by AI agents. Key fields included in the response taxonomy are:

Field Description
ID The unique numerical identifier for a user or tweet.
Metrics Real-time counts for likes, retweets, and replies.
Bio/Text The descriptive content of a profile or the body of a tweet.
Timestamps ISO-formatted dates for tweet creation and account history.
URL Direct links to the specific content on the X platform.

X (Twitter) API Integration Advanced Features

  • Advanced Search Operators: Full support for complex queries like from:, to:, and -filter:retweets to refine data extraction.
  • Batch Tweet Lookup: Efficiently retrieve data for multiple tweet IDs in a single request to optimize rate limit usage.
  • Deduplication Awareness: Designed to respect X's 24-hour billing deduplication window for cost-effective data fetching.
  • Stateless Architecture: A thread-safe CLI design that allows for parallel execution within complex Openclaw Skills pipelines.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*