Release v1.20.0: Add twitter-reader skill
- Add twitter-reader v1.0.0 for Twitter/X content fetching via Jina.ai API - Implement secure API key management using environment variables - Support individual and batch tweet fetching with bundled scripts - Include Python (fetch_tweet.py) and Bash (fetch_tweets.sh) scripts - Update marketplace to v1.20.0 (26 → 27 skills) - Update all documentation (README.md, README.zh-CN.md, CLAUDE.md) - Security: Remove hardcoded API keys, enforce HTTPS, add validation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
4
twitter-reader/.security-scan-passed
Normal file
4
twitter-reader/.security-scan-passed
Normal file
@@ -0,0 +1,4 @@
|
||||
Security scan passed
|
||||
Scanned at: 2026-01-11T15:27:31.794239
|
||||
Tool: gitleaks + pattern-based validation
|
||||
Content hash: 2349813d82b8932f89fdc653c0dde1b2335483478227653554553b59007975c1
|
||||
72
twitter-reader/SKILL.md
Normal file
72
twitter-reader/SKILL.md
Normal file
@@ -0,0 +1,72 @@
|
||||
---
|
||||
name: twitter-reader
|
||||
description: Fetch Twitter/X post content by URL using jina.ai API to bypass JavaScript restrictions. Use when Claude needs to retrieve tweet content including author, timestamp, post text, images, and thread replies. Supports individual posts or batch fetching from x.com or twitter.com URLs.
|
||||
---
|
||||
|
||||
# Twitter Reader
|
||||
|
||||
Fetch Twitter/X post content without needing JavaScript or authentication.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
You need a Jina API key to use this skill:
|
||||
|
||||
1. Visit https://jina.ai/ to sign up (free tier available)
|
||||
2. Get your API key from the dashboard
|
||||
3. Set the environment variable:
|
||||
|
||||
```bash
|
||||
export JINA_API_KEY="your_api_key_here"
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
For a single tweet, use curl directly:
|
||||
|
||||
```bash
|
||||
curl "https://r.jina.ai/https://x.com/USER/status/TWEET_ID" \
|
||||
-H "Authorization: Bearer ${JINA_API_KEY}"
|
||||
```
|
||||
|
||||
For multiple tweets, use the bundled script:
|
||||
|
||||
```bash
|
||||
scripts/fetch_tweets.sh url1 url2 url3
|
||||
```
|
||||
|
||||
## What Gets Returned
|
||||
|
||||
- **Title**: Post author and content preview
|
||||
- **URL Source**: Original tweet link
|
||||
- **Published Time**: GMT timestamp
|
||||
- **Markdown Content**: Full post text with media descriptions
|
||||
|
||||
## Bundled Scripts
|
||||
|
||||
### fetch_tweet.py
|
||||
|
||||
Python script for fetching individual tweets.
|
||||
|
||||
```bash
|
||||
python scripts/fetch_tweet.py https://x.com/user/status/123 output.md
|
||||
```
|
||||
|
||||
### fetch_tweets.sh
|
||||
|
||||
Bash script for batch fetching multiple tweets.
|
||||
|
||||
```bash
|
||||
scripts/fetch_tweets.sh \
|
||||
"https://x.com/user/status/123" \
|
||||
"https://x.com/user/status/456"
|
||||
```
|
||||
|
||||
## URL Formats Supported
|
||||
|
||||
- `https://x.com/USER/status/ID`
|
||||
- `https://twitter.com/USER/status/ID`
|
||||
- `https://x.com/...` (redirects work automatically)
|
||||
|
||||
## Environment Variables
|
||||
|
||||
- `JINA_API_KEY`: Required. Your Jina.ai API key for accessing the reader API
|
||||
66
twitter-reader/scripts/fetch_tweet.py
Executable file
66
twitter-reader/scripts/fetch_tweet.py
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Fetch Twitter/X post content using jina.ai API.
|
||||
|
||||
Usage:
|
||||
python fetch_tweet.py <tweet_url> [output_file]
|
||||
|
||||
Example:
|
||||
python fetch_tweet.py https://x.com/dabit3/status/2009131298250428923 tweet.md
|
||||
|
||||
Requires:
|
||||
JINA_API_KEY environment variable set with your Jina.ai API key
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def fetch_tweet(url: str, output_file: str = None) -> str:
|
||||
"""Fetch tweet content using jina.ai API via curl."""
|
||||
api_key = os.getenv("JINA_API_KEY")
|
||||
if not api_key:
|
||||
print("Error: JINA_API_KEY environment variable is not set", file=sys.stderr)
|
||||
print("Get your API key from https://jina.ai/ and set:", file=sys.stderr)
|
||||
print(" export JINA_API_KEY='your_api_key_here'", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
jina_api_url = f"https://r.jina.ai/{url}"
|
||||
|
||||
cmd = [
|
||||
"curl", "-s", jina_api_url,
|
||||
"-H", f"Authorization: Bearer {api_key}"
|
||||
]
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(f"Error fetching tweet: {result.stderr}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
content = result.stdout
|
||||
|
||||
if output_file:
|
||||
Path(output_file).write_text(content, encoding="utf-8")
|
||||
print(f"Saved to {output_file}")
|
||||
|
||||
return content
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Fetch Twitter/X post content")
|
||||
parser.add_argument("url", help="Twitter/X post URL")
|
||||
parser.add_argument("output", nargs="?", help="Optional output file path")
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.url.startswith(("https://x.com/", "https://twitter.com/")):
|
||||
print("Error: URL must be from x.com or twitter.com (HTTPS only)", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
content = fetch_tweet(args.url, args.output)
|
||||
|
||||
if not args.output:
|
||||
print(content)
|
||||
31
twitter-reader/scripts/fetch_tweets.sh
Executable file
31
twitter-reader/scripts/fetch_tweets.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
# Fetch Twitter/X post content using jina.ai API
|
||||
# Usage: ./fetch_tweets.sh <url1> [url2] ...
|
||||
# Requires: JINA_API_KEY environment variable
|
||||
|
||||
if [ -z "$JINA_API_KEY" ]; then
|
||||
echo "Error: JINA_API_KEY environment variable is not set" >&2
|
||||
echo "Get your API key from https://jina.ai/ and set:" >&2
|
||||
echo " export JINA_API_KEY='your_api_key_here'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: $0 <tweet_url> [tweet_url2] ..."
|
||||
echo "Example: $0 https://x.com/dabit3/status/2009131298250428923"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for url in "$@"; do
|
||||
if [[ ! "$url" =~ ^https?://(x\.com|twitter\.com)/ ]]; then
|
||||
echo "Skipping invalid URL: $url" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Fetching: $url"
|
||||
curl -s "https://r.jina.ai/${url}" \
|
||||
-H "Authorization: Bearer ${JINA_API_KEY}"
|
||||
echo ""
|
||||
echo "---"
|
||||
echo ""
|
||||
done
|
||||
Reference in New Issue
Block a user