GET /post/by-url

Posts by URL

Posts that submitted one exact link. Reddit Scraper API endpoint /post/by-url: parameters, JSON response fields and code examples.

Every Reddit post that submitted one exact web page (an article, a product page, a video), most-commented first, up to 25 per page. A link nobody submitted answers an empty list; for every post linking anywhere on a website use /domain/posts. Billed 1 request per page.

HTTP Request

GET /post/by-url

Cost (in requests): 1 per page. Every successful answer reports its cost in data.billed_requests.

Parameters

ParameterTypeRequiredDefaultDescription
linkstringYes-Full address of the page (https://example.com/some/page, scheme optional). Matching is exact apart from the scheme, a #fragment and a trailing slash: www. and http-vs-https as submitted on Reddit count as different links when Reddit indexed them separately; try both spellings if a page was shared both ways.
page_tokenstringNo-Opaque page token from a previous response’s next_page_token. Omit for the first page.
per_pageintegerNo25Posts per page, 1–25 (default 25). Reddit’s search also returns posts of similar links; they are taken out, so a page can hold fewer.
include_htmlbooleanNofalseAdds body_html (the rendered HTML body) to every post and comment. Default: left out; body_text carries the same text.

Response

Real response to GET /post/by-url?link=https://peps.python.org/pep-0851/ (arrays trimmed to 2 items, long texts cut with …).

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{
  "status": true,
  "request_id": "a4d3bfb7-d5c2-5f18-6dea-6cb59989",
  "data": {
    "items": [],
    "has_next_page": false,
    "next_page_token": null,
    "resolved_filters": {
      "link": {
        "input": "https://peps.python.org/pep-0851/",
        "resolved": "peps.python.org/pep-0851",
        "source": "param"
      }
    },
    "billed_requests": 1
  },
  "request_params": {
    "link": "https://peps.python.org/pep-0851/"
  }
}

Response Fields

FieldTypeDescription
statusbooleantrue when the request succeeded
request_idstringUnique request identifier
dataobjectPosts that submitted the link (empty list when nobody did); null with error.code invalid_page_token.
data.itemsarrayPosts that submitted this link, most comments first, 1-based position counted across pages. Each card’s url is the link as the author submitted it.
data.has_next_pagebooleanMore posts available.
data.next_page_tokenstring / nullToken for the next page; null at the end.
data.resolved_filtersobjectThe link as sent and as looked up.
data.resolved_filters.linkobjectinput = the address as sent; resolved = the normalised link the lookup used (no scheme, no #fragment, no trailing slash).
data.resolved_filters.link.inputstringWhat the caller sent.
data.resolved_filters.link.resolvedstringWhat was applied on Reddit (null when not applied).
data.resolved_filters.link.sourcestringparam (applied as given), default, not_found (the value does not exist on Reddit), private / banned / quarantined (a community in the scope that cannot be read: skipped), or not_available (translate_to only: Reddit had no translated listing, the rows are served in their original language).
data.billed_requestsintegerRequests billed for this call (also sent as Requests in the X-RapidAPI-Billing header when it is not RapidAPI’s default of 1).
request_paramsobjectEcho of the parameters you sent

Error Responses

Invalid input returns HTTP 400, not billed. error is a plain string that names the parameter:

1
{ "status": false, "request_id": "99a1e6cd-2e57-9e8f-4e44-2dea7f6d", "error": "Invalid parameter 'post_id': must be a post id such as z1c9z or t3_z1c9z", "request_params": { "post_id": "!!" } }
Status CodeCauseDescription
400Invalid or missing parameterPlain-English message per field. Not billed
200 with status: falseItem not availableerror.code is not_found, deleted (post removed or deleted). data is null. Billed 1 request
503Reddit temporarily unreachable"error": "Service temporarily unavailable". Not billed, retry later
200 with status: falseBad page tokenerror.code is invalid_page_token: pass next_page_token from the previous answer unchanged

Code Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import requests

url = "https://reddit-scraper-api-extractor-ai-the-most-complete.p.rapidapi.com/post/by-url"

params = {
    "link": "https://peps.python.org/pep-0851/",
}

headers = {
    "X-RapidAPI-Key": "YOUR_API_KEY",
    "X-RapidAPI-Host": "reddit-scraper-api-extractor-ai-the-most-complete.p.rapidapi.com"
}

response = requests.get(url, headers=headers, params=params)
data = response.json()["data"]

print(data["has_next_page"])
print(data["next_page_token"])
print("Billed requests:", data["billed_requests"])
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
const url = "https://reddit-scraper-api-extractor-ai-the-most-complete.p.rapidapi.com/post/by-url";

const params = new URLSearchParams({
  link: "https://peps.python.org/pep-0851/",
});

const response = await fetch(`${url}?${params}`, {
  headers: {
    "X-RapidAPI-Key": "YOUR_API_KEY",
    "X-RapidAPI-Host": "reddit-scraper-api-extractor-ai-the-most-complete.p.rapidapi.com"
  }
});

const { data } = await response.json();
console.log(data.has_next_page, data.next_page_token);
1
2
3
4
curl -G "https://reddit-scraper-api-extractor-ai-the-most-complete.p.rapidapi.com/post/by-url" \
  --data-urlencode "link=https://peps.python.org/pep-0851/" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: reddit-scraper-api-extractor-ai-the-most-complete.p.rapidapi.com"
Start building today

Get your API key and make your first request in under a minute.

Get Your API Key on RapidAPI