+ Integration Guide
Reddit API npm Package for JavaScript & TypeScript
Use the official @fetchlayer/reddit npm package to search Reddit, scrape posts and comments, and work with typed Reddit API responses in JavaScript or TypeScript.
- reddit npm package
- reddit api npm
- reddit javascript sdk
- reddit typescript sdk
- reddit scraper npm
If you want a Reddit API package for JavaScript or TypeScript, the cleanest option is now @fetchlayer/reddit.
It’s the official FetchLayer SDK for Reddit data: open source, MIT-licensed, typed, and designed for Node.js apps that need Reddit search, posts, comments, subreddit data, user profiles, and discovery endpoints without dealing with Reddit OAuth.
GitHub repo: fetchlayer-dev/reddit-scraper-js
Install
npm install @fetchlayer/reddit
Works with:
- JavaScript
- TypeScript
- Node.js 18+
- ESM and CommonJS
Get an API key
- Create a free FetchLayer account
- Copy your API key
- Set
FETCHLAYER_API_KEY
No Reddit account required. No OAuth app registration. No credit card to start.
Quick Start
import { FetchLayerReddit } from '@fetchlayer/reddit';
const reddit = new FetchLayerReddit({
apiKey: process.env.FETCHLAYER_API_KEY!,
});
const results = await reddit.searchPosts({
query: 'best CRM for startups',
sort: 'top',
limit: 5,
});
for (const post of results.items ?? []) {
console.log(`${post.title} — r/${post.subreddit} — ${post.score}`);
}
That gives you structured Reddit data in a few lines, without building your own wrapper around fetch().
What You Can Do With It
@fetchlayer/reddit covers all 13 FetchLayer Reddit endpoints:
- Search Reddit posts by keyword
- Get a full Reddit post and its comments
- Fetch a specific comment permalink
- List posts from any subreddit
- Get subreddit metadata
- Fetch Reddit user profiles
- List a user’s posts and comments
- Search subreddits
- Search users
- Get trending posts
- Get community leaderboards
- Explore communities by topic
- Resolve a Reddit URL to its type
If you need the full REST endpoint list, see the FetchLayer API reference.
Why Use the Package Instead of Raw fetch()
- Cleaner code in Node.js and TypeScript projects
- Typed response interfaces included by default
- One client for all Reddit endpoints
- Built-in error handling with
FetchLayerError - Zero runtime dependencies
- Open-source SDK you can inspect on GitHub
You can still call the REST API directly if you want. The package just removes boilerplate.
Example: Get a Post With Comments
import { FetchLayerReddit } from '@fetchlayer/reddit';
const reddit = new FetchLayerReddit({
apiKey: process.env.FETCHLAYER_API_KEY!,
});
const thread = await reddit.getPost({
url: 'https://www.reddit.com/r/programming/comments/abc123/some_post/',
commentLimit: 50,
commentDepth: 3,
});
console.log(thread.title);
console.log(thread.commentCount);
console.log(thread.comments?.length ?? 0);
Example: Search Communities in TypeScript
import { FetchLayerReddit } from '@fetchlayer/reddit';
const reddit = new FetchLayerReddit({
apiKey: process.env.FETCHLAYER_API_KEY!,
});
const communities = await reddit.searchCommunities({
query: 'machine learning',
limit: 10,
});
for (const community of communities.items ?? []) {
console.log(community.subredditPrefixed, community.title);
}
npm Package or Direct API?
Use the package if:
- you’re in Node.js or TypeScript
- you want typed responses
- you want faster setup
- you want a cleaner developer experience
Use raw HTTP if:
- you’re in Python, Go, Bun, or another language
- you want total control over your wrapper
- you’re building from a non-JS runtime
Same backend API either way.
Related Guides
- Reddit API with Node.js
- Reddit API with TypeScript
- PRAW Alternative for JavaScript & Node.js Developers
- How to Scrape Reddit in 2026
- Best Reddit Scraper APIs in 2026
Links
- npm: @fetchlayer/reddit
- GitHub: fetchlayer-dev/reddit-scraper-js
- Product page: FetchLayer Reddit Scraper API
- Get API key: fetchlayer.dev/signin