TypeScript SDK
The official SubScraper SDK is the easiest way to access Reddit data in your Node.js or browser application. Full TypeScript types, a clean promise-based API, and zero configuration beyond your API key.
Installation
npm install @subscraper/sdk
Requires Node.js 18+ or any modern browser runtime.
Need an API key?
Create a free account. 30 requests included, no credit card required.
Initialize
Import and instantiate the client once at the top of your file or module:
import { SubScraperClient } from '@subscraper/sdk';
const client = new SubScraperClient({
apiKey: 'sk-your-api-key-here' // Get from dashboard
});Examples
searchSearch Reddit Posts
// Search Reddit posts by keyword
const result = await client.searchPosts({
query: 'nextjs server components',
limit: 10,
sort: 'top',
time: 'year'
});
console.log(result.results);
// [{ title: "...", subreddit: "...", score: 412, ... }]Full search endpoint docs →user-profileGet User Profile
// Fetch a user's karma, bio, and account age
const profile = await client.getUserProfile({
username: 'shittymorph'
});
console.log(`Total karma: ${profile.karma.post + profile.karma.comment}`);Full user-profile endpoint docs →community-postsFetch Subreddit Posts
// Get hot posts from a subreddit
const feed = await client.getCommunityPosts({
subreddit: 'MachineLearning',
sort: 'hot',
limit: 25
});
console.log(feed.posts);Full community-posts endpoint docs →postGet Post + Comment Tree
// Fetch a post and its full comment tree
const thread = await client.getPost({
url: 'https://reddit.com/r/webdev/comments/abc123/...',
commentLimit: 100
});
console.log(thread.title);
console.log(thread.comments); // Nested treeFull post endpoint docs →All Available Methods
| Method | Endpoint |
|---|---|
| searchPosts() | /search |
| getPost() | /post |
| getCommunityPosts() | /community-posts |
| getCommunityDetails() | /community-details |
| getUserProfile() | /user-profile |
| getUserPosts() | /user-posts |
| getUserComments() | /user-comments |
| searchCommunities() | /search-communities |
| searchUsers() | /search-users |
| getCommentPermalink() | /comment-permalink |
| getPopular() | /popular |
| getLeaderboard() | /leaderboard |
| resolveUrlType() | /resolve-url-type |
| explore() | /explore |
Start building today
Free tier includes 30 requests. No credit card required.