Reddit Data API
EN

Reddit Data API · GET · JSON

From a raw response to an accepted warehouse batch

Work through raw landing, source-to-column mapping, validation, rejection handling and batch promotion using a small historical Reddit response.

Conceptual illustration, not a screenshot or measured result.

Questions about this page

What is this example intended to produce?

Suppose the destination is a table for examining the text and recorded score of historical posts from python.

Which inputs should I keep?

Request https://api.redditdataapi.com/v1/posts?subreddit=python&limit=3 from your server and save the actual response before conversion.

What source-to-output mapping is needed?

List only properties you observe or explicitly handle as optional.

Which objects should be rejected or separated?

A rejected row should point back to its raw object and explain the failed rule.

How is this selection defined?

Test revised transformations against the same saved input before inserting accepted rows into the destination.

When is another API request justified?

Fetch more material when the next batch serves a defined validation or analysis need.

How much does Reddit Data API cost?

The price is $1 per 1,000 successful requests. The minimum top-up is $50 for 50,000 credits. Each successful request uses one credit, even when it returns no matching records. Invalid requests are not charged; upstream failures trigger a refund, which can require reconciliation. A timeout alone does not establish the final billing outcome.

Can I reuse the same key on another domain?

No. Accounts, API keys and credit balances are separated by site. Use the key issued for this domain with its own HTTPS API hostname. Keep that key in server-side configuration, not in browser JavaScript, public repositories or shared logs. A key from another site is not a substitute for a local account. Google sign-in is shared across the network; API keys and balances remain separate for each site.

1. Name the output you need

Suppose the destination is a table for examining the text and recorded score of historical posts from python. Define the intended row meaning before the table columns: one accepted source post, with your batch metadata kept separately. This is a proposed local warehouse design, not a statement that the API supplies every property or every post you might need.

2. Keep an untouched landing copy

Request https://api.redditdataapi.com/v1/posts?subreddit=python&limit=3 from your server and save the actual response before conversion. Store the route, nonsecret parameters, retrieval time and loader version beside it. The archive is independent, historical and unofficial. A returned page is neither live Reddit nor evidence of complete community coverage; an empty successful page is a valid input to the job.

3. Write the source-to-column map

List only properties you observe or explicitly handle as optional. For id, decide whether the destination accepts the source string unchanged. For title and text, define how omitted properties differ from null and empty strings. For score, accept the numeric forms your validation contract permits instead of quietly converting absence to zero.

For created_utc, verify the source value and unit before choosing a timestamp conversion. Keep the original when a conversion fails. Give each local column a clear name and record the rule that produced it. If parent_id or link_id occurs, optional local linking is possible, but it does not establish a complete thread or ancestor chain.

4. Make rejection useful

A rejected row should point back to its raw object and explain the failed rule. Separate type errors from deliberate exclusions so the operator can choose between fixing a mapping and changing the selection policy. Retain accepted, rejected and excluded counts for this batch. Such counts describe your processing of received data, not the volume of activity on Reddit.

5. Promote a batch deliberately

Test revised transformations against the same saved input before inserting accepted rows into the destination. If suitable source identifiers are available, document how your loader handles a repeated object. The API does not guarantee unique records across pages. Keep raw landing and normalized output separate so a later schema revision does not overwrite the evidence used to justify the earlier load.

Advance a local checkpoint only after the required files and loading outcome have been recorded. A checkpoint helps your application track its work; it is not a stable server cursor. Retrieval uses _doc order, not chronological or relevance order, and is bounded by 100 records per request and 100 pages per query.

6. Know when to fetch again

Fetch more material when the next batch serves a defined validation or analysis need. Do not refetch solely to rerun a local conversion. A future remote response can differ; reproducibility here means retaining inputs and transformation versions for your own processing. Detailed date filters, totals and response codes belong in the documentation, and the pricing page explains charged successes, upstream reservation refunds and separately charged successful retries. The result of this exercise is a reviewable load procedure, not an exhaustive or immutable archive export.

Make your first authenticated request

Create an account, copy the key shown at the top of the account page, and put it in a server environment variable. The three examples below request the same small page. Inspect the HTTP status before using the JSON; keep credentials out of browser bundles, shared notebooks and request logs.

cURL

curl --get --fail-with-body 'https://api.redditdataapi.com/v1/posts' \
  -H "Authorization: Bearer ${REDDIT_API_KEY}" \
  --data-urlencode 'subreddit=python' \
  --data-urlencode 'limit=3'

Python

import json
import os
from urllib.parse import urlencode
from urllib.request import Request, urlopen

params = urlencode({"subreddit":"python","limit":"3"})
request = Request(
    "https://api.redditdataapi.com/v1/posts?" + params,
    headers={"Authorization": "Bearer " + os.environ["REDDIT_API_KEY"]},
)
with urlopen(request, timeout=20) as response:
    payload = json.load(response)

print(payload["pagination"])
print(payload["data"])

Node.js 18+

// Node.js 18+ · example.mjs
const parameters = new URLSearchParams({"subreddit":"python","limit":"3"});
const response = await fetch(
  "https://api.redditdataapi.com/v1/posts?" + parameters,
  {headers: {Authorization: "Bearer " + process.env.REDDIT_API_KEY}}
);
if (!response.ok) throw new Error("HTTP " + response.status);
const payload = await response.json();
console.log(payload.pagination);
console.log(payload.data);

Read the response before building a table

This is an illustrative empty successful response, not a live query result. An empty page still costs one credit. Read data, pagination and credits separately; a total must always be interpreted with relation. The balance shown is an example after one eligible trial request.

{
  "data": [],
  "pagination": {
    "page": 1,
    "limit": 3,
    "total": 0,
    "relation": "eq",
    "has_more": false,
    "window_exhausted": false,
    "truncated": false
  },
  "credits": {
    "cost": 1,
    "balance": 4999
  }
}

Response

Inspect the actual objects before assuming a column exists. Keep omitted values, null and empty strings distinct. Relationship fields, when returned, may help with local grouping; they do not establish a complete thread. Preserve the raw response so a revised mapping can be tested without paying to fetch it again.

Combine ordinary text with an exact community and a UTC date window. Keep the nonsecret query parameters with the saved response. Limit controls the page size, page selects a bounded offset, and min_score is a filter rather than a sorting option. A page order is not a chronological or relevance ranking.

Six routes, one read-only API contract

Choose the route for the object you need. Search selects posts and comments; posts and comments constrain the record kind. Item looks up a known id. Subreddits returns matching community names rather than a complete community dataset. Status is an uncharged service-scope response and does not test search availability.

MethodAPIUse
GET/v1/searchSearch posts and comments
GET/v1/postsPosts only
GET/v1/commentsComments only
GET/v1/itemOne known record id
GET/v1/subredditsCommunity names by prefix
GET/v1/statusService scope; no charge

Set the boundaries of a collection job

Combine ordinary text with an exact community and a UTC date window. Keep the nonsecret query parameters with the saved response. Limit controls the page size, page selects a bounded offset, and min_score is a filter rather than a sorting option. A page order is not a chronological or relevance ranking.

ParameterMeaning
qText in title and text
subredditExact community spelling
authorExact author value
kindpost or comment
from / toYYYY-MM-DD, UTC; end day included
min_scoreMinimum score, not sorting
limit / pageBoth range from 1 to 100
prefix / idRoute-specific name prefix or known id

Map observed fields deliberately

Inspect the actual objects before assuming a column exists. Keep omitted values, null and empty strings distinct. Relationship fields, when returned, may help with local grouping; they do not establish a complete thread. Preserve the raw response so a revised mapping can be tested without paying to fetch it again.

ParameterMeaning
idKeep the source identifier
kindInspect the record kind
subredditPreserve the returned community name
title / textTreat missing, null and empty separately
created_utc / scoreCheck numeric values before conversion
parent_id / link_idOptional links; group locally if present
Conceptual illustration, not a screenshot or measured result.

Where this archive API fits

Use this service when your task starts with reading available historical records. A live feed, posting, editing, voting or a server-built thread requires a different integration. Direct page scraping and official Reddit access have their own behaviour and requirements; this endpoint does not impersonate either interface or promise their coverage.

How do search, posts and comments differ?

Use /v1/search for the supported search across record kinds. /v1/posts and /v1/comments add a post or comment constraint. They share the documented search filters; /v1/item is the separate route for a known id. None of these routes creates, edits or deletes Reddit content.

How is this different from scraping Reddit pages?

You request structured historical records through the documented routes instead of downloading current HTML and extracting page elements. This avoids making your loader depend on page markup. It does not provide a live proxy, browser session, official OAuth compatibility or a promise of complete historical coverage.

Documentation

Architecture and Data Model Constraints

Building an ingestion pipeline starts with recognizing an independent historical archive, not a live or official Reddit interface. Keep an original response sample, a query manifest, and the version of your transformation rules. These local artifacts help you explain a warehouse row later. They do not guarantee that the archive preserves a record or returns the same data on another run.

The API returns flat records rather than pre-assembled thread trees, meaning you must group parent and link relationships locally if those fields are present in the payload. The server does not provide complete ancestry guarantees, and there are no exposed query filters for parent_id or link_id to fetch all comments for a specific post directly. Clients must retrieve supported filtered flat records and group them conditionally when the fields exist, recognizing that a complete conversation history is never guaranteed by the service design.

Inspect returned fields such as id, kind, subreddit, created_utc, score, title and text before choosing local column types. This is a list of fields to inspect, not a promise that every record contains every field. Distinguish missing values, nulls and failed conversions. Send unexpected shapes to a local review area instead of silently turning them into accepted warehouse rows.

Endpoint Routing and Query Semantics

Authenticated GET requests use https://api.redditdataapi.com with either X-API-Key: <key> or Authorization: Bearer <key>. Use /v1/search for supported searches, /v1/posts for posts, and /v1/comments for comments. Only /v1/item requires id for direct lookup of a known record. The id parameter is not a posts or comments filter; those routes do not provide a server-built discussion tree.

Search filters are q, subreddit, author, kind, from, to, min_score, limit and page. kind accepts post or comment. Dates use YYYY-MM-DD in UTC, with to including the stated day. min_score filters a numeric score and never sorts results. The internal _doc order is neither chronological nor relevance order. No arbitrary query DSL or server-side custom analytics is exposed.

Set limit from 1 to 100 and page from 1 to 100; each request fetches one page. The /v1/subreddits route accepts prefix and limit, without guaranteeing globally exact aggregation counts. Read totals with relation: eq is exact, gte a lower bound, unknown unreliable and potentially null. Exhausting the permitted pages does not prove complete coverage. Group returned parent_id or link_id fields locally only when present; neither field is a supported query filter.

Error Handling, Pricing, and Reliability

Handle HTTP 400 for an invalid request, 401 for a missing or invalid key, 402 for insufficient credit, and 429 for a rate limit. Correct invalid parameters before retrying, check credentials for 401, and pause or fund the job for 402. Apply a bounded wait for rate limits. Inspect the response status before treating the body as a successful batch of records.

Each successful retrieval consumes one credit, including an empty response. Invalid requests do not debit credits and upstream failures refund reservations. A client may lose its connection after a successful server retrieval; if a repeated request succeeds, it costs another credit. Keep an attempt log separate from your local validation results, because rejecting a record in your loader does not reverse a successful API charge.

The public /v1/status route is uncharged and provides static service-scope information plus evidence that the HTTP app responds. It does not probe search or record availability. Keys and balances belong to redditdataapi.com. Keep your key in server configuration. Account sessions use a separate cookie; signing into the account panel does not replace a retrieval authentication header.

Keeping and replacing your key

API key

Your API key is stored encrypted and is available after sign-in. Keep it private.

Keep the key on your server. Regeneration immediately disables the previous key. Your credits and account remain available.

Recovering account access

Save this one-time code privately. You need your email and this code to reset a forgotten password. A new code replaces the previous one.

Continue with Google

An existing account can be linked when Google establishes authoritative ownership of the email. Other email addresses require confirmation with the existing account password.

Request records and local copies

Request activity · last 30 days

Detailed request records, including client IP and user agent, are kept for 30 days.

Summaries cover the selected period. IP, response and latency details are available only for logged requests and expire after 30 days. Older records may lack these fields.

Requests

The export contains the currently displayed page and filters. Times use your browser timezone; chart days use UTC.

Reddit Data API is an independent historical archive service, not an official Reddit product or a live mirror. Availability of a record, time range or optional field is not guaranteed. Record the scope and retrieval time of your own batch, review the terms and privacy information, and avoid presenting a bounded archive sample as all activity on Reddit. The account exposes request costs, statuses and available client details; older requests may lack IP or latency fields.

Request costs you can account for

$1 / 1,000

A successful retrieval costs one credit, including an empty result: $1 per 1,000 successes. Eligible new accounts receive $5 = 5,000 credits once across the network. The minimum paid top-up is $50 = 50,000 credits. Invalid requests are not charged; upstream failures refund the reservation, sometimes after reconciliation. A successful retry is a new paid retrieval, so rerun local transformations from saved inputs first.

$5 / 5,000

Welcome credit: $5 · 5,000 credits

$50 / 50,000

Create an invoice before sending. Send exactly the displayed amount using the displayed token and network. Credit is added only after blockchain confirmation.

Conceptual illustration, not a screenshot or measured result.

Continue with the related reference