A Deno-powered HTTP service that turns Reddit subreddit RSS feeds into structured JSON, complete with filtering, sorting, merging, and random selection utilities.
asc, desc) or shuffle them (mixed).count while retaining the original itemsLength for reference.old.reddit.com on demand for legacy views.[Deno.serve](https://deno.land/api?s=Deno.serve) with a zero-dependency runtime.https://reddit-rss-api.deno.devGET /): renders the Markdown README as HTML for quick documentation access.GET /r/{subreddits}): fetches RSS-derived JSON for one or more subreddits.subreddits – one or more subreddit names separated by + (URL-encoded space). Example: deno+typescript.option (string)
randomnullsort (string)
asc, desc, mixedascmixed). Applied before count.filter (string)
image, video, image+videonull+ (decoded as space).merge (boolean)
true, falsefalsetrue, the API fetches each subreddit individually and merges the results.count (number)
>= 1nullold_reddit (boolean)
true, falsefalseold.reddit.com.Combine parameters to compose custom feeds. Validation errors produce informative
400 Bad Requestmessages. Whenoption=randomis used, the response is a singleExtractedItemobject instead of the full feed payload.
curl "https://reddit-rss-api.deno.dev/r/deno"
curl "https://reddit-rss-api.deno.dev/r/deno+typescript?merge=true&filter=image"
curl "https://reddit-rss-api.deno.dev/r/memes+videos?filter=video&option=random&old_reddit=true"
curl "https://reddit-rss-api.deno.dev/r/pics?sort=desc&count=5"
type ResponseData = {
title: string;
lastBuildDate: Date;
link: string;
feedUrl: string;
itemsLength?: number;
items: ExtractedItem[];
};
type ExtractedItem = {
title: string;
link: string;
author: string;
isoDate: Date;
feedURL: string;
id: string;
message?: string;
links?: string[];
images?: string[];
videos?: string[];
};
Sample response (GET /r/deno?count=2):
{
"title": "posts from r/deno",
"lastBuildDate": "2024-04-09T12:34:56.000Z",
"link": "https://www.reddit.com/r/deno/",
"feedUrl": "https://www.reddit.com/r/deno/.rss",
"itemsLength": 2,
"items": [
{
"title": "Deno 1.41 release highlights",
"link": "https://www.reddit.com/r/deno/comments/abc123/...",
"author": "user123",
"isoDate": "2024-04-09T09:12:34.000Z",
"feedURL": "https://www.reddit.com/r/deno/.rss",
"id": "t3_abc123",
"links": ["https://example.com/blog-post"],
"images": ["https://i.redd.it/xyz.png"]
},
{
"title": "Working with kv storage",
"link": "https://www.reddit.com/r/deno/comments/def456/...",
"author": "user456",
"isoDate": "2024-04-08T16:20:10.000Z",
"feedURL": "https://www.reddit.com/r/deno/.rss",
"id": "t3_def456"
}
]
}
400 Bad Request for invalid paths, malformed query parameters, or RSS parsing failures.405 Method Not Allowed for non-GET requests.To contribute to the project, follow these steps:
Run the server:
deno run start
The service listens on http://localhost:8000 by default.
deno run start – run the API once with full permissions.deno run dev – watch mode for local development.deno run test – execute the unit test suite under src/tests/.deno run fmt – format codebase.index.ts – HTTP entry point. Routes requests, serves the README as HTML, and wires query processing.src/utils/fetch.ts – Fetches and parses RSS feeds with rss-parser, normalizes links, and extracts items.src/utils/handlers.ts – Orchestrates query parameter handling (merge, sort, filter, random, count, old Reddit toggles).src/utils/utils.ts – Shared helpers (CORS responses, merged feed builder, numeric validation).src/utils/extracters.ts – Parses HTML content, surfaces media URLs, and rewrites Reddit domains when requested.src/utils/html.ts – Renders the README through deno_dom for the root HTML response.src/tests/tests.ts – Unit tests verifying feed parsing, query validation, and Reddit URL construction.Run the full suite with:
deno run test
Tests rely on live Reddit RSS endpoints; ensure you have network access when executing them.