Fetch twitter

From markerikson/opencode-config-example · View interactive version

Fetch twitter is an AI agent skill from the GitHub repository markerikson/opencode-config-example. Fetch tweet content using Twitter's syndication API (no auth required). Use when processing Twitter/X URLs to get tweet text, author info, and metadata.

How to use this skill

Skill file

Fetch Twitter/X Content

Fetch tweet content using Twitter's syndication API (the same endpoint used for tweet embeds).

Quick Usage

bun ~/.config/opencode/skill/fetch-twitter/fetch-twitter.js <tweet_url_or_id>

Examples

# From full URL
bun ~/.config/opencode/skill/fetch-twitter/fetch-twitter.js https://x.com/shanselman/status/2006301298933604666

# From tweet ID only
bun ~/.config/opencode/skill/fetch-twitter/fetch-twitter.js 2006301298933604666

Output Format

{
  "id": "2006301298933604666",
  "url": "https://x.com/shanselman/status/2006301298933604666",
  "author": {
    "name": "Scott Hanselman",
    "handle": "@shanselman",
    "verified": true
  },
  "text": "Full tweet text...",
  "created": "2025-12-31T09:47:59.000Z",
  "favorites": 389,
  "hasMedia": false,
  "mediaType": null,
  "quotedTweet": {
    "author": "@davidfowl",
    "text": "Quoted tweet text...",
    "url": "https://x.com/davidfowl/status/..."
  }
}

How It Works

Twitter's syndication API (cdn.syndication.twimg.com) is used for tweet embeds and doesn't require authentication. It requires a token calculated from the tweet ID:

function getToken(id) {
  return ((Number(id) / 1e15) * Math.PI)
    .toString(36)
    .replace(/(0+|\.)/g, '');
}

The endpoint is: https://cdn.syndication.twimg.com/tweet-result?id={tweetId}&token={token}

Limitations

When to Use

When processing Twitter URLs:

  1. Detect x.com or twitter.com URLs
  2. Run: bun ~/.config/opencode/skill/fetch-twitter/fetch-twitter.js <url>
  3. Parse the JSON output
  4. Use text, author.name, author.handle for the markdown entry
  5. Note hasMedia and mediaType if relevant
  6. Include quotedTweet context if present
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.