TwtAPI - Twitter/X Data
Access live Twitter/X data through TwtAPI's hosted skill gateway. Search tweets, look up users, read timelines, browse followers, and check trends with structured JSON built for AI agents. Get your skill key at https://www.twtapi.com/en/.
Setup
- 1. Install the public skill:
CODEBLOCK0
- 2. Sign up and open the
Skill tab in your TwtAPI dashboard. - Copy your dedicated
skill_key. - Set the required environment variable:
CODEBLOCK1
The public hosted gateway https://skill.twtapi.com is built in by default, so most users do not need to set a base URL.
If you are overriding the gateway for a self-hosted or custom deployment, you can optionally set:
CODEBLOCK2
If you use OpenClaw, you can also set skills."twtapi".env.TWTAPI_SKILL_KEY in ~/.openclaw/openclaw.json. Other compatible skill runners only need an equivalent way to inject TWTAPI_SKILL_KEY.
Verify the skill connection
Run this first after setup:
CODEBLOCK3
If auth and routing are correct, you should get a JSON list of available skill tools.
Usage
Search tweets
CODEBLOCK4
Look up a user profile
CODEBLOCK5
Get user tweets / replies / media
Requires a numeric user ID. Look up the user first if you only have a username.
CODEBLOCK6
Get a single tweet by ID
CODEBLOCK7
List followers / following
CODEBLOCK8
Get trending topics
CODEBLOCK9
Workflow tips
- - Username → user ID: run
user <username> first, then use the rest_id from the result for tweets, followers, etc. - Pagination: most list commands accept
--cursor for the next page. The cursor value is included in the response when more results are available. - Search operators: the
search command supports Twitter search syntax — from:handle, to:handle, #hashtag, lang:en, date ranges, etc.
Notes
- - This skill uses TwtAPI's hosted public gateway plus your dedicated
skill_key, not your main API key. - The hosted gateway is built in. Most end users only need
TWTAPI_SKILL_KEY. - Each API call consumes credits from your TwtAPI account.
- Returns raw Twitter JSON from the TwtAPI skill backend. Present results in a readable format with post content, author names, metrics, and timestamps.
- Rate limits and credit balance are managed by your plan.
TwtAPI - Twitter/X 数据
通过 TwtAPI 托管的技能网关访问实时 Twitter/X 数据。搜索推文、查找用户、阅读时间线、浏览关注者以及查看趋势,所有数据均以专为 AI 智能体构建的结构化 JSON 格式返回。请访问 https://www.twtapi.com/en/ 获取您的技能密钥。
设置
- 1. 安装公共技能:
clawhub install twtapi
- 2. 注册并打开 TwtAPI 控制面板中的 Skill 标签页。
- 复制您的专属 skill_key。
- 设置所需的环境变量:
export TWTAPISKILLKEY=tsk-your-skill-key
默认已内置公共托管网关 https://skill.twtapi.com,因此大多数用户无需设置基础 URL。
如果您需要覆盖网关以进行自托管或自定义部署,可以选择设置:
export TWTAPISKILLBASE_URL=https://your-skill-host.example.com
如果您使用 OpenClaw,也可以在 ~/.openclaw/openclaw.json 中设置 skills.twtapi.env.TWTAPISKILLKEY。其他兼容的技能运行器只需以等效方式注入 TWTAPISKILLKEY 即可。
验证技能连接
设置完成后,首先运行以下命令:
python3 {baseDir}/scripts/twtapi.py tools
如果认证和路由配置正确,您将获得可用技能工具的 JSON 列表。
使用方法
搜索推文
python3 {baseDir}/scripts/twtapi.py search AI agents
python3 {baseDir}/scripts/twtapi.py search #bitcoin --type Top --count 10
python3 {baseDir}/scripts/twtapi.py search from:elonmusk --cursor scroll_xxx
查找用户资料
python3 {baseDir}/scripts/twtapi.py user elonmusk
python3 {baseDir}/scripts/twtapi.py user-by-id 44196397
获取用户推文/回复/媒体
需要数字用户 ID。如果您只有用户名,请先查找用户。
python3 {baseDir}/scripts/twtapi.py tweets 44196397
python3 {baseDir}/scripts/twtapi.py tweets 44196397 --count 5
python3 {baseDir}/scripts/twtapi.py replies 44196397
python3 {baseDir}/scripts/twtapi.py media 44196397
通过 ID 获取单条推文
python3 {baseDir}/scripts/twtapi.py tweet 1897023456789012345
列出关注者/正在关注
python3 {baseDir}/scripts/twtapi.py followers 44196397 --count 50
python3 {baseDir}/scripts/twtapi.py following 44196397
获取热门话题
python3 {baseDir}/scripts/twtapi.py trending
工作流程提示
- - 用户名 → 用户 ID:先运行 user ,然后使用结果中的 rest_id 进行 tweets、followers 等操作。
- 分页:大多数列表命令接受 --cursor 参数用于获取下一页。当有更多结果可用时,响应中会包含光标值。
- 搜索运算符:search 命令支持 Twitter 搜索语法——from:handle、to:handle、#hashtag、lang:en、日期范围等。
注意事项
- - 此技能使用 TwtAPI 托管的公共网关加上您的专属 skillkey,而不是您的主 API 密钥。
- 托管网关已内置。大多数最终用户只需设置 TWTAPISKILL_KEY。
- 每次 API 调用都会消耗您 TwtAPI 账户中的积分。
- 返回来自 TwtAPI 技能后端的原始 Twitter JSON。请以可读格式呈现结果,包括帖子内容、作者名称、指标和时间戳。
- 速率限制和积分余额由您的套餐管理。