A subreddit's posts with their score and comment count, keyword search across Reddit or one subreddit, and comments by post or subreddit, as typed JSON.
A subreddit's posts with their score and comment count, keyword search across Reddit or one subreddit, and comments by post or subreddit, as typed JSON.
At a glance
Three GET endpoints under /v1/structured/reddit/. Each answers { endpoint, url, credits, duration_ms, data }; data is described below and in the reference. Each call is charged for the data it moves; a page we could not read is 502 TARGET_FAILED and costs nothing, and a subreddit or post that does not exist is a free 404 NOT_FOUND.
Endpoint | What | Typical |
|---|---|---|
| A subreddit's posts, | about 375,000 posts per credit, about 25 per call |
| Posts matching | about 600,000 results per credit, up to 100 per call |
| One | about 2 million comments per credit, up to 100 per call |
Subreddit posts
Parameter | Type | Default | Description |
|---|---|---|---|
| string | — | The subreddit, e.g. |
|
|
| Listing order. |
|
|
| With |
| string | — | The |
- cURL
- Python
- Node.js
curl -G "https://api.scrapelyserp.com/v1/structured/reddit/posts" \
-H "Authorization: Bearer $SCRAPELY_API_KEY" \
-d subreddit=webscraping \
-d sort=newimport os
import requests
HEADERS = {"Authorization": f"Bearer {os.environ['SCRAPELY_API_KEY']}"}
r = requests.get(
"https://api.scrapelyserp.com/v1/structured/reddit/posts",
headers=HEADERS,
params={"subreddit": "webscraping", "sort": "new"},
timeout=30,
)
r.raise_for_status()
data = r.json()
for p in data["data"]["posts"]:
print(p["score"], p["comments"], p["title"])const res = await fetch(`https://api.scrapelyserp.com/v1/structured/reddit/posts?${new URLSearchParams({ subreddit: 'webscraping', sort: 'new' })}`, {
headers: { Authorization: `Bearer ${process.env.SCRAPELY_API_KEY}` },
signal: AbortSignal.timeout(30_000),
});
if (!res.ok) throw new Error((await res.json()).error.code);
const data = await res.json();
for (const p of data.data.posts) console.log(p.score, p.comments, p.title);Each post has id, subreddit, title, author, url, link (where a link post points), created_at, score, comments, upvote_ratio, type (text, link, image, video…), domain, flair and text. Promoted posts are left out. Pass next_cursor back as cursor for the next page.
Full reference → GET /v1/structured/reddit/posts
Search
Parameter | Type | Default | Description |
|---|---|---|---|
| string | — | The search terms. |
| string | — | Search only this subreddit, e.g. |
|
|
| Result order. |
|
|
| Only posts from this window. |
| integer |
| Results per page, 1–100. |
| string | — | The |
Results carry id, subreddit, title, author, url, created_at and text (score and comment counts are on posts). To be told about each new mention, put the query on a mention list.
Full reference → GET /v1/structured/reddit/search
Comments
Parameter | Type | Default | Description |
|---|---|---|---|
| string | — | A post's id (e.g. |
| string | — | A subreddit, e.g. |
|
|
| With |
| integer |
| Results per page, 1–100. |
| string | — | With |
With post, data.post is the post itself and comments its comments. With subreddit, comments are its newest across every post, each with post_id and post_title, and next_cursor pages further back.
Full reference → GET /v1/structured/reddit/comments