### Docker Deployment with Redis Cache and GitHub Token Source: https://context7.com/diygod/rsshub/llms.txt Deploy RSSHub using Docker with Redis as the cache. This example also shows how to set a GitHub access token and an access key for authentication. ```bash # Run with Redis cache and GitHub token docker run -d \ --name rsshub \ -p 1200:1200 \ -e CACHE_TYPE=redis \ -e REDIS_URL=redis://redis:6379 \ -e GITHUB_ACCESS_TOKEN=ghp_xxxx \ -e ACCESS_KEY=mysecretkey \ diygod/rsshub ``` -------------------------------- ### Run RSSHub Development Environment Source: https://github.com/diygod/rsshub/blob/master/scripts/ansible/README.md Use this command for development after installing Vagrant. It first executes a script and then runs the Ansible playbook. ```bash ./try.sh ansible-playbook rsshub.yaml ``` -------------------------------- ### Retrieve RSSHub Namespace Registry Metadata Source: https://context7.com/diygod/rsshub/llms.txt Use `GET /api/namespace` to get metadata for all registered namespaces, including name, URL, categories, language, description, and route definitions. ```bash curl https://rsshub.app/api/namespace # { # "github": { # "name": "GitHub", # "url": "github.com", # "categories": ["programming"], # "routes": { # "/trending/:since/:language/:spoken_language?": { # "name": "Trending", # "path": "/trending/:since/:language/:spoken_language?", # "example": "/github/trending/daily/javascript/en", # "maintainers": ["DIYgod"], # "features": { ... }, # } # } # } # } ``` -------------------------------- ### Making HTTP Requests with `got` Utility Source: https://context7.com/diygod/rsshub/llms.txt Use this utility for making various HTTP requests (GET, POST, PUT, PATCH, DELETE) with support for query parameters, JSON/form bodies, and custom headers. It's a `got`-compatible facade built on `ofetch`. ```typescript import got from '@/utils/got'; // GET with query params const { data } = await got('https://api.example.com/posts', { searchParams: { page: 1, per_page: 20 }, headers: { Authorization: 'Bearer TOKEN' }, }); ``` ```typescript // POST with JSON body const result = await got.post('https://api.example.com/graphql', { json: { query: `query { viewer { login } }`, }, headers: { Authorization: 'bearer GITHUB_TOKEN' }, }); ``` ```typescript // POST with form body const formResult = await got.post('https://example.com/login', { form: { username: 'user', password: 'pass' }, }); ``` ```typescript // Binary/buffer response const { data: buffer } = await got('https://example.com/image.png', { responseType: 'buffer', }); ``` ```typescript // Extended instance with default options const apiClient = got.extend({ headers: { 'X-API-Key': 'mykey' }, }); const { data: apiData } = await apiClient('https://api.example.com/resource'); ``` -------------------------------- ### Test RSSHub Routes Source: https://context7.com/diygod/rsshub/llms.txt Test specific RSSHub routes after deployment using `curl`. Examples include fetching trending GitHub repositories and GitHub issues in Atom format. ```bash # Test a route curl http://localhost:1200/github/trending/daily/javascript curl http://localhost:1200/github/issue/DIYgod/RSSHub?format=atom ``` -------------------------------- ### Minimal Route Handler Returning Data Source: https://context7.com/diygod/rsshub/llms.txt A basic example of a route handler function that must return a `Data` object. Ensure the `Data` and `DataItem` types are imported. ```typescript import type { Data, DataItem } from 'rsshub'; // or '@/types' internally // A minimal route handler returning Data const handler = async (ctx): Promise => { return { title: 'My Feed Title', link: 'https://example.com', description: 'Feed description', language: 'en', image: 'https://example.com/logo.png', item: [ { title: 'Article One', link: 'https://example.com/article-1', description: '

HTML content of the article

', pubDate: new Date('2024-06-01'), author: [{ name: 'Jane Doe', url: 'https://example.com/jane' }], category: ['tech', 'rss'], guid: 'unique-guid-001', enclosure_url: 'https://example.com/audio.mp3', enclosure_type: 'audio/mpeg', itunes_duration: 3600, // seconds, auto-converted to HH:MM:SS } satisfies DataItem, ], }; }; ``` -------------------------------- ### Configure Anti-Hotlink Image Proxy Source: https://context7.com/diygod/rsshub/llms.txt Use `image_hotlink_template` with a user-supplied template (e.g., `https://imageproxy.example.com/${href_ue}`) to enable an anti-hotlink image proxy. Requires `ALLOW_USER_HOTLINK_TEMPLATE=true`. ```bash # Anti-hotlink image proxy (user-supplied template, requires ALLOW_USER_HOTLINK_TEMPLATE=true) curl "https://rsshub.app/hackernews?image_hotlink_template=https://imageproxy.example.com/${href_ue}" ``` -------------------------------- ### Deploy RSSHub with Ansible Source: https://github.com/diygod/rsshub/blob/master/scripts/ansible/README.md Run the Ansible playbook to deploy RSSHub. Requires sudo permissions. ```bash sudo ansible-playbook rsshub.yaml ``` -------------------------------- ### RSSHub Environment Configuration - OpenAI and Route-Specific Source: https://context7.com/diygod/rsshub/llms.txt Configure settings for OpenAI integration, such as API key and model, and route-specific environment variables like GitHub access tokens or Bilibili cookies. ```bash # OpenAI (for ?chatgpt= parameter) OPENAI_API_KEY=sk-xxxx OPENAI_MODEL=gpt-4o-mini OPENAI_PROMPT=Summarize this article in 3 sentences. # Route-specific (examples) GITHUB_ACCESS_TOKEN=ghp_xxxx BILIBILI_COOKIE_123456=SESSDATA=xxx; bili_jct=xxx DISCORD_AUTHORIZATION=Bot your_bot_token ``` -------------------------------- ### Docker Compose Deployment Source: https://context7.com/diygod/rsshub/llms.txt Deploy RSSHub using Docker Compose. Ensure you have the `docker-compose.yml` file in your repository and run this command in the same directory. ```bash # With docker-compose (included in repo) docker compose up -d ``` -------------------------------- ### RSSHub Environment Configuration - Server and Cache Source: https://context7.com/diygod/rsshub/llms.txt Configure RSSHub server settings like port and access key, and cache settings including type, Redis URL, and expiration times for routes and content. ```bash # Server PORT=1200 ACCESS_KEY=your_secret_key # Require auth for all routes # Cache CACHE_TYPE=redis # 'memory' | 'redis' | 'http' (default: memory) REDIS_URL=redis://localhost:6379 CACHE_EXPIRE=300 # Route cache TTL in seconds (default: 300) CACHE_CONTENT_EXPIRE=3600 # Content cache TTL in seconds (default: 3600) ``` -------------------------------- ### RSSHub Environment Configuration - Proxy and Puppeteer Source: https://context7.com/diygod/rsshub/llms.txt Configure proxy settings for routing requests and Puppeteer settings for browser automation, including proxy URI, strategy, and Puppeteer WebSocket endpoint. ```bash # Proxy PROXY_URI=http://user:pass@proxy.example.com:8080 PROXY_STRATEGY=rotate # 'default' | 'rotate' # Puppeteer PUPPETEER_WS_ENDPOINT=ws://browserless:3000 CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium ``` -------------------------------- ### Generate OpenAI Summary for RSS Feed Items Source: https://context7.com/diygod/rsshub/llms.txt Use the `chatgpt=1` query parameter to generate summaries for feed items using OpenAI. Requires `OPENAI_API_KEY` to be configured. ```bash # OpenAI summary (requires OPENAI_API_KEY config) curl "https://rsshub.app/hackernews?chatgpt=1" ``` -------------------------------- ### Redirect to New Documentation Source: https://github.com/diygod/rsshub/blob/master/assets/404.html This JavaScript code alerts the user about the documentation change and then redirects their browser to the new documentation site. ```javascript alert('The documentation has been changed to docs.rsshub.app and will be automatically redirected to the new documentation page.'); window.location.href = 'https://docs.rsshub.app'; ``` -------------------------------- ### Enable Full-Text RSS Feed Mode Source: https://context7.com/diygod/rsshub/llms.txt Use the `mode=fulltext` query parameter to fetch the complete article content using the Mercury parser. ```bash # Full-text mode: fetch full article content via Mercury parser curl "https://rsshub.app/hackernews?mode=fulltext" ``` -------------------------------- ### Authenticate RSSHub Access with Access Key Source: https://context7.com/diygod/rsshub/llms.txt When `ACCESS_KEY` is set, use `key` for direct authentication or `code` (MD5 of path + key) for per-path access. Unauthorized access results in a 403 error. ```bash # Set ACCESS_KEY=mysecret in environment # Direct key access curl "https://rsshub.app/github/trending/daily/any?key=mysecret" ``` ```javascript # Per-path code: MD5 of (path + key) # path = /github/trending/daily/any, key = mysecret # code = md5("/github/trending/daily/anymysecret") import { createHash } from 'crypto'; const code = createHash('md5').update('/github/trending/daily/any' + 'mysecret').digest('hex'); curl `https://rsshub.app/github/trending/daily/any?code=${code}` ``` ```bash # Unauthorized access returns 403 curl "https://rsshub.app/github/trending/daily/any" # → {"message":"Authentication failed. Access denied."} ``` -------------------------------- ### Truncate RSS Feed Descriptions with `brief` Source: https://context7.com/diygod/rsshub/llms.txt Use the `brief` query parameter followed by a number (>= 100) to truncate item descriptions to the specified character count. ```bash # Brief: truncate descriptions to N characters (N >= 100) curl "https://rsshub.app/hackernews?brief=200" ``` -------------------------------- ### Specify RSS Feed Output Format Source: https://context7.com/diygod/rsshub/llms.txt Use the `format` query parameter to choose the output format for the feed, supporting 'rss' (default), 'atom', 'json', and 'rss3'. ```bash # Output format: rss (default), atom, json, rss3 curl "https://rsshub.app/github/trending/daily/any?format=atom" curl "https://rsshub.app/github/trending/daily/any?format=json" ``` -------------------------------- ### Implementing Cache-Aside with `cache.tryGet` Source: https://context7.com/diygod/rsshub/llms.txt This helper facilitates the cache-aside pattern, checking configured cache backends before fetching data. Configure the cache type using the `CACHE_TYPE` environment variable. The default TTL is `CACHE_CONTENT_EXPIRE` (1 hour). ```typescript import cache from '@/utils/cache'; // Cache a single item with default TTL (CACHE_CONTENT_EXPIRE, default 1 hour) const articleContent = await cache.tryGet( `my-route:article:${articleId}`, async () => { const { data } = await got(`https://example.com/article/${articleId}`); return data.content; // string or object } ); ``` ```typescript // Cache with custom TTL (seconds) and disable refresh-on-hit const userData = await cache.tryGet( `my-route:user:${userId}`, async () => { const { data } = await got(`https://api.example.com/users/${userId}`); return { name: data.name, avatar: data.avatar_url }; }, 60 * 60 * 24, // 24-hour TTL false // don't refresh TTL on cache hit ); ``` ```typescript // Low-level get/set await cache.set('my-key', 'my-value', 300); // 300s TTL const val = await cache.get('my-key'); ``` ```typescript // Check if key exists without fetching const exists = await cache.globalCache.has('my-key'); ``` -------------------------------- ### RSSHub npm Package Usage Source: https://context7.com/diygod/rsshub/llms.txt Use the RSSHub npm package to programmatically fetch feeds or register custom routes. Initialize the package with optional configuration and then use `request` to fetch data. ```typescript import { init, request, registerRoute } from 'rsshub'; import type { Route } from 'rsshub'; // Initialize with optional config overrides await init({ CACHE_TYPE: 'memory', CACHE_EXPIRE: '300', // Any env config key is valid here }); // Fetch a built-in route – returns Data object const githubTrending = await request('/github/trending/daily/javascript'); console.log(githubTrending.title); // "Trending" console.log(githubTrending.item[0]); // { title, link, description, ... } // Fetch with parameters const issues = await request('/github/issue/DIYgod/RSSHub/open'); // Register a custom route at runtime const myRoute: Route = { path: '/latest', name: 'Latest Posts', maintainers: ['me'], example: '/myblog/latest', handler: async () => ({ title: 'My Blog', link: 'https://myblog.com', item: [ { title: 'Hello World', link: 'https://myblog.com/hello', description: '

First post

' }, ], }), }; await registerRoute('myblog', myRoute, { name: 'My Blog', url: 'myblog.com' }); const myFeed = await request('/myblog/latest'); ``` -------------------------------- ### npm Package API Source: https://context7.com/diygod/rsshub/llms.txt RSSHub can be used as an npm package to programmatically fetch any feed or register custom routes. ```APIDOC ## npm Package API: `init`, `request`, `registerRoute` ### Description RSSHub can be used as an npm package (`import { init, request, registerRoute } from 'rsshub'`) to programmatically fetch any feed or register custom routes. ### Methods - **init(config?: object)**: Initializes RSSHub with optional configuration overrides. - **request(routePath: string, options?: object)**: Fetches a feed from a given route path. - **registerRoute(namespace: string, route: Route, config?: object)**: Registers a custom route at runtime. ### Types - **Route**: An object defining a custom route with properties like `path`, `name`, `maintainers`, `example`, and `handler`. ### Request Example (TypeScript) ```typescript import { init, request, registerRoute } from 'rsshub'; import type { Route } from 'rsshub'; // Initialize with optional config overrides await init({ CACHE_TYPE: 'memory', CACHE_EXPIRE: '300', // Any env config key is valid here }); // Fetch a built-in route – returns Data object const githubTrending = await request('/github/trending/daily/javascript'); console.log(githubTrending.title); // "Trending" console.log(githubTrending.item[0]); // { title, link, description, ... } // Fetch with parameters const issues = await request('/github/issue/DIYgod/RSSHub/open'); // Register a custom route at runtime const myRoute: Route = { path: '/latest', name: 'Latest Posts', maintainers: ['me'], example: '/myblog/latest', handler: async () => ({ title: 'My Blog', link: 'https://myblog.com', item: [ { title: 'Hello World', link: 'https://myblog.com/hello', description: '

First post

' }, ], }), }; await registerRoute('myblog', myRoute, { name: 'My Blog', url: 'myblog.com' }); const myFeed = await request('/myblog/latest'); ``` ``` -------------------------------- ### RSSHub Configuration Variables Source: https://context7.com/diygod/rsshub/llms.txt These variables control the behavior of RSSHub. Ensure they are set correctly in your environment. ```shell TITLE_LENGTH_LIMIT=100 ``` ```shell FILTER_REGEX_ENGINE=re2 ``` ```shell DISABLE_NSFW=true ``` -------------------------------- ### Enable Telegram Instant View for RSS Feeds Source: https://context7.com/diygod/rsshub/llms.txt Use the `tgiv` query parameter with your Telegram Instant View `rHash` to enable Telegram Instant View for feed items. ```bash # Telegram Instant View curl "https://rsshub.app/hackernews?tgiv=YOUR_RHASH" ``` -------------------------------- ### REST API: Radar Rules Source: https://context7.com/diygod/rsshub/llms.txt Returns all RSSHub Radar browser-extension rules, grouped by domain and subdomain. ```APIDOC ## GET /api/radar/rules ### Description Returns all RSSHub Radar browser-extension rules, grouped by domain and subdomain. ### Method GET ### Endpoint /api/radar/rules ### Parameters #### Query Parameters - **domain** (string) - Optional - Filters rules for a specific domain. ### Request Example ```bash # Get all rules curl https://rsshub.app/api/radar/rules # Get rules for a specific domain curl https://rsshub.app/api/radar/rules/github.com ``` ### Response #### Success Response (200) - **(object)** - An object where keys are domains and values are objects containing rules for that domain. #### Response Example ```json { "github.com": { "_name": "GitHub", ".": [ { "title": "Trending", "docs": "https://docs.rsshub.app/routes/programming", "source": ["/trending"], "target": "/github/trending/:since" } ] }, "youtube.com": { ... } } ``` ``` -------------------------------- ### REST API: Namespace Registry Source: https://context7.com/diygod/rsshub/llms.txt Retrieves metadata for all registered namespaces, including their names, URLs, categories, languages, descriptions, and route definitions. ```APIDOC ## REST API: Namespace Registry — `GET /api/namespace` Returns metadata for all registered namespaces (name, URL, categories, language, description, and all route definitions). ```bash curl https://rsshub.app/api/namespace # { # "github": { # "name": "GitHub", # "url": "github.com", # "categories": ["programming"], # "routes": { # "/trending/:since/:language/:spoken_language?": { # "name": "Trending", # "path": "/trending/:since/:language/:spoken_language?", # "example": "/github/trending/daily/javascript/en", # "maintainers": ["DIYgod"], # "features": { ... }, # ... # } # } ``` ``` -------------------------------- ### Limit the Number of Items in an RSS Feed Source: https://context7.com/diygod/rsshub/llms.txt Use the `limit` query parameter to control the maximum number of items returned in the feed. ```bash # Limit number of items curl "https://rsshub.app/github/issue/DIYgod/RSSHub?limit=10" ``` -------------------------------- ### Docker Deployment with Default Cache Source: https://context7.com/diygod/rsshub/llms.txt Deploy RSSHub using Docker with the default in-memory cache. This command runs RSSHub in detached mode and maps port 1200. ```bash # Run with default in-memory cache docker run -d \ --name rsshub \ -p 1200:1200 \ diygod/rsshub ``` -------------------------------- ### Route Definition for GitHub Issues Source: https://context7.com/diygod/rsshub/llms.txt Defines a route for fetching GitHub repository issues. It uses the `got` utility for API requests and maps the API response to the `Data` object structure. Requires `Route` and `ViewType` types. ```typescript import type { Route } from '@/types'; import { ViewType } from '@/types'; import got from '@/utils/got'; export const route: Route = { path: '/issue/:user/:repo/:state?/:labels?', name: 'Repo Issues', url: 'github.com', categories: ['programming'], view: ViewType.Notifications, example: '/github/issue/DIYgod/RSSHub/open', maintainers: ['HenryQW'], parameters: { user: 'GitHub username', repo: 'GitHub repo name', state: { description: 'Issue state', default: 'open', options: [ { value: 'open', label: 'Open' }, { value: 'closed', label: 'Closed' }, { value: 'all', label: 'All' }, ], }, labels: 'Comma-separated label names', }, features: { requireConfig: [{ name: 'GITHUB_ACCESS_TOKEN', optional: true, description: 'GitHub personal access token' }], antiCrawler: false, supportRadar: true, }, radar: [ { source: ['github.com/:user/:repo/issues', 'github.com/:user/:repo'], target: '/issue/:user/:repo', }, ], handler: async (ctx) => { const { user, repo } = ctx.req.param(); const state = ctx.req.param('state') ?? 'open'; const { data } = await got(`https://api.github.com/repos/${user}/${repo}/issues`, { searchParams: { state, sort: 'created', direction: 'desc', per_page: 30 }, }); return { title: `${user}/${repo} Issues`, link: `https://github.com/${user}/${repo}/issues`, item: data.map((issue) => ({ title: issue.title, link: issue.html_url, description: issue.body ?? '', pubDate: new Date(issue.created_at), author: issue.user.login, category: issue.labels.map((l) => l.name), })), }; }, }; ``` -------------------------------- ### Use Puppeteer to Scrape JavaScript-Rendered Pages Source: https://context7.com/diygod/rsshub/llms.txt Use `getPuppeteerPage` for scraping dynamic content. It handles browser lifecycle, proxies, and anti-detection. Custom hooks like `onBeforeLoad` can intercept requests. ```typescript import { getPuppeteerPage } from '@/utils/puppeteer'; import type { Route } from '@/types'; export const route: Route = { path: '/js-rendered/:id', name: 'JS Rendered Page', features: { requirePuppeteer: true }, maintainers: ['me'], example: '/mysite/js-rendered/123', handler: async (ctx) => { const id = ctx.req.param('id'); const url = `https://example.com/content/${id}`; // Basic usage – navigates to URL and waits for page load const { page, browser } = await getPuppeteerPage(url); const content = await page.evaluate(() => document.querySelector('.content')?.innerHTML); browser.close(); // With custom hook before navigation (e.g. intercept requests) const { page: page2, browser: browser2 } = await getPuppeteerPage(url, { onBeforeLoad: async (p) => { await p.setRequestInterception(true); p.on('request', (req) => { if (req.resourceType() === 'image') { req.abort(); } else { req.continue(); } }); }, gotoConfig: { waitUntil: 'networkidle2' }, }); const title = await page2.title(); browser2.close(); return { title: `Content ${id}`, link: url, item: [{ title, link: url, description: content ?? '' }], }; }, }; ``` -------------------------------- ### Access Control Source: https://context7.com/diygod/rsshub/llms.txt Details on how to secure RSSHub feeds using an access key, supporting direct key authentication and per-path MD5 codes. ```APIDOC ## Access Control (Middleware: access-control.ts) When `ACCESS_KEY` is set, all non-root routes require authentication via query parameter `key` (direct key) or `code` (MD5 of path + key for per-path access). ```bash # Set ACCESS_KEY=mysecret in environment # Direct key access curl "https://rsshub.app/github/trending/daily/any?key=mysecret" # Per-path code: MD5 of (path + key) # path = /github/trending/daily/any, key = mysecret # code = md5("/github/trending/daily/anymysecret") import { createHash } from 'crypto'; const code = createHash('md5').update('/github/trending/daily/any' + 'mysecret').digest('hex'); curl `https://rsshub.app/github/trending/daily/any?code=${code}` # Unauthorized access returns 403 curl "https://rsshub.app/github/trending/daily/any" # → {"message":"Authentication failed. Access denied."} ``` ``` -------------------------------- ### Perform Chinese Text Conversion with OpenCC Source: https://context7.com/diygod/rsshub/llms.txt Use the `opencc` query parameter with values like `s2t` (Simplified to Traditional) or `t2s` for Chinese text conversion in feeds. ```bash # OpenCC Chinese conversion: s2t (Simplified→Traditional), t2s, etc. curl "https://rsshub.app/weibo/user/123456?opencc=s2t" ``` -------------------------------- ### Retrieve RSSHub Radar Rules API Source: https://context7.com/diygod/rsshub/llms.txt This API endpoint returns all RSSHub Radar browser-extension rules, organized by domain and subdomain. You can fetch all rules or filter by a specific domain. ```bash curl https://rsshub.app/api/radar/rules # { # "github.com": { # "_name": "GitHub", # ".": [ # { # "title": "Trending", # "docs": "https://docs.rsshub.app/routes/programming", # "source": ["/trending"], # "target": "/github/trending/:since" # } # ] # }, # "youtube.com": { ... } # } # Single domain rules curl https://rsshub.app/api/radar/rules/github.com ``` -------------------------------- ### Filter RSS Feed Items by Title, Description, or Author Source: https://context7.com/diygod/rsshub/llms.txt Use the `filter` query parameter to keep items matching a regex in title, description, or author. For field-specific filtering, use `filter_title`, `filter_author`, etc. ```bash # Filter: keep only items matching regex in title, description, author, or category curl "https://rsshub.app/github/trending/daily/javascript?filter=react|vue" ``` ```bash # Filter by field curl "https://rsshub.app/hackernews?filter_title=AI&filter_author=pg" ``` -------------------------------- ### Puppeteer Integration: getPuppeteerPage Source: https://context7.com/diygod/rsshub/llms.txt Utility function for scraping JavaScript-rendered pages. It handles browser lifecycle, proxy integration, and anti-detection settings automatically. ```APIDOC ## Puppeteer Integration: `getPuppeteerPage` `@/utils/puppeteer` exports `getPuppeteerPage` for scraping JavaScript-rendered pages. It manages browser lifecycle, proxy integration, and anti-detection settings automatically. ```typescript import { getPuppeteerPage } from '@/utils/puppeteer'; import type { Route } from '@/types'; export const route: Route = { path: '/js-rendered/:id', name: 'JS Rendered Page', features: { requirePuppeteer: true }, maintainers: ['me'], example: '/mysite/js-rendered/123', handler: async (ctx) => { const id = ctx.req.param('id'); const url = `https://example.com/content/${id}`; // Basic usage – navigates to URL and waits for page load const { page, browser } = await getPuppeteerPage(url); const content = await page.evaluate(() => document.querySelector('.content')?.innerHTML); browser.close(); // With custom hook before navigation (e.g. intercept requests) const { page: page2, browser: browser2 } = await getPuppeteerPage(url, { onBeforeLoad: async (p) => { await p.setRequestInterception(true); p.on('request', (req) => { if (req.resourceType() === 'image') { req.abort(); } else { req.continue(); } }); }, gotoConfig: { waitUntil: 'networkidle2' }, }); const title = await page2.title(); browser2.close(); return { title: `Content ${id}`, link: url, item: [{ title, link: url, description: content ?? '' }], }; }, }; ``` ``` -------------------------------- ### Check Route Cache Status API Source: https://context7.com/diygod/rsshub/llms.txt Use this API to check if a feed path is currently cached and when it was last built. It returns a 200 status for cached, 404 for not cached, and 503 if the cache module is unavailable. ```bash # Check cache for a specific route path curl "https://rsshub.app/api/route/status?requestPath=/github/comments/DIYgod/RSSHub/20768" # Cached response (HTTP 200): # { "cached": true, "lastBuildDate": "Sat, 01 Jun 2024 12:00:00 GMT" } # Not cached (HTTP 404): # { "cached": false, "lastBuildDate": null } # Cache module unavailable (HTTP 503): # { "cached": false, "lastBuildDate": null } ``` -------------------------------- ### Feed Query Parameters Source: https://context7.com/diygod/rsshub/llms.txt Standard query parameters accepted by all RSSHub feeds for filtering, limiting, formatting, and other processing. ```APIDOC ## Feed Query Parameters (Middleware: parameter.ts) All RSSHub feeds accept standard query parameters that are processed by `lib/middleware/parameter.ts`. These work on any route without any route-specific code. ```bash # Filter: keep only items matching regex in title, description, author, or category curl "https://rsshub.app/github/trending/daily/javascript?filter=react|vue" # Filter by field curl "https://rsshub.app/hackernews?filter_title=AI&filter_author=pg" # Filterout: exclude matching items curl "https://rsshub.app/reddit/r/programming?filterout=hiring|job" # Filter by time (seconds): only items published within the last hour curl "https://rsshub.app/twitter/user/elonmusk?filter_time=3600" # Limit number of items curl "https://rsshub.app/github/issue/DIYgod/RSSHub?limit=10" # Output format: rss (default), atom,سری, json, rss3 curl "https://rsshub.app/github/trending/daily/any?format=atom" curl "https://rsshub.app/github/trending/daily/any?format=json" # Full-text mode: fetch full article content via Mercury parser curl "https://rsshub.app/hackernews?mode=fulltext" # OpenAI summary (requires OPENAI_API_KEY config) curl "https://rsshub.app/hackernews?chatgpt=1" # Brief: truncate descriptions to N characters (N >= 100) curl "https://rsshub.app/hackernews?brief=200" # Telegram Instant View curl "https://rsshub.app/hackernews?tgiv=YOUR_RHASH" # OpenCC Chinese conversion: s2t (Simplified→Traditional), t2s, etc. curl "https://rsshub.app/weibo/user/123456?opencc=s2t" # Disable sorting by pubDate curl "https://rsshub.app/hackernews?sorted=false" # Anti-hotlink image proxy (user-supplied template, requires ALLOW_USER_HOTLINK_TEMPLATE=true) curl "https://rsshub.app/hackernews?image_hotlink_template=https://imageproxy.example.com/\${href_ue}" ``` ``` -------------------------------- ### Exclude RSS Feed Items Using `filterout` Source: https://context7.com/diygod/rsshub/llms.txt Use the `filterout` query parameter to exclude items that match the provided regex in their title, description, author, or category. ```bash # Filterout: exclude matching items curl "https://rsshub.app/reddit/r/programming?filterout=hiring|job" ``` -------------------------------- ### Filter RSS Feed Items by Publication Time Source: https://context7.com/diygod/rsshub/llms.txt Use the `filter_time` query parameter to retrieve items published within a specified number of seconds from the current time. ```bash # Filter by time (seconds): only items published within the last hour curl "https://rsshub.app/twitter/user/elonmusk?filter_time=3600" ``` -------------------------------- ### Parsing Absolute and Relative Dates with `parseDate` Source: https://context7.com/diygod/rsshub/llms.txt Utilize `parseDate` for absolute date strings (supporting custom formats) and `parseRelativeDate` for natural language and relative date strings in English and Chinese. These functions normalize diverse date formats. ```typescript import { parseDate, parseRelativeDate } from '@/utils/parse-date'; // parseDate: wraps dayjs for absolute date strings parseDate('2024-06-15T12:00:00Z'); // → Date object parseDate('June 15, 2024'); // → Date object parseDate('15/06/2024', 'DD/MM/YYYY'); // → Date object with custom format ``` ```typescript // parseRelativeDate: handles relative and semantic strings parseRelativeDate('2 hours ago'); // → Date (now - 2h) parseRelativeDate('3 days ago'); // → Date (now - 3d) parseRelativeDate('just now'); // → Date (now - 3s) parseRelativeDate('in 10 minutes'); // → Date (now + 10m) parseRelativeDate('yesterday'); // → start of yesterday parseRelativeDate('今天 3pm'); // → today at 15:00 parseRelativeDate('周五下午3点'); // → last Friday at 15:00 parseRelativeDate('昨天 10:00'); // → yesterday at 10:00 parseRelativeDate('Monday'); // → start of last Monday ``` ```typescript // Typical usage inside a route handler: const items = posts.map((post) => ({ title: post.title, link: post.url, pubDate: parseRelativeDate(post.publishedAt), // e.g. "3小时前" })); ``` -------------------------------- ### Disable Sorting by Publication Date Source: https://context7.com/diygod/rsshub/llms.txt Set `sorted=false` in the query parameters to disable the default sorting of feed items by their publication date. ```bash # Disable sorting by pubDate curl "https://rsshub.app/hackernews?sorted=false" ``` -------------------------------- ### REST API: Route Cache Status Source: https://context7.com/diygod/rsshub/llms.txt Checks whether a given feed path is currently cached and when it was last built. ```APIDOC ## GET /api/route/status ### Description Checks whether a given feed path is currently cached (and when it was last built). ### Method GET ### Endpoint /api/route/status ### Parameters #### Query Parameters - **requestPath** (string) - Required - The path of the route to check. ### Request Example ```bash curl "https://rsshub.app/api/route/status?requestPath=/github/comments/DIYgod/RSSHub/20768" ``` ### Response #### Success Response (200) - **cached** (boolean) - Indicates if the route is cached. - **lastBuildDate** (string) - The last build date of the cache in GMT format. #### Response Example ```json { "cached": true, "lastBuildDate": "Sat, 01 Jun 2024 12:00:00 GMT" } ``` #### Not Cached Response (404) ```json { "cached": false, "lastBuildDate": null } ``` #### Cache Module Unavailable Response (503) ```json { "cached": false, "lastBuildDate": null } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.