---
title: "Listings and pages"
description: "The envelope every list endpoint returns, how to page through it, and how NSFW items are filtered."
---

> Documentation Index
> Fetch the complete documentation index at: https://threadapi.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Listings and pages

Every endpoint that returns a list of posts, comments, subreddits or users answers with the same envelope:

```jsonc
{
  "subreddit": "golang",      // the subreddit asked for, or null
  "query": null,              // the search query, or null
  "sort": "top",              // the sort Reddit applied
  "count": 3,                 // items in this page
  "items": [ /* posts or comments */ ],
  "after": "t3_1x0vbyx",      // pass back as after= for the next page; null on the last
  "filtered_nsfw": 0          // NSFW items left out of this page
}
```

The item type depends on the endpoint: [Subreddit](/api/Reddit/listSubredditPosts/), [Search posts](/api/Reddit/searchPosts/) and [User posts](/api/Reddit/getUserPosts/) return posts; [Subreddit comments](/api/Reddit/getSubredditComments/), [User comments](/api/Reddit/getUserComments/) and [Comment search](/api/Reddit/searchComments/) return comments.

## Pages

Pass the previous page's `after` to get the next one. Each page is one call and 1 credit.

### cURL

```bash
curl "https://api.threadapi.dev/v1/reddit/subreddit/posts?sub=golang&sort=new&limit=100&after=t3_1x0vbyx" \
  -H "Authorization: Bearer $THREADAPI_API_KEY"
```

### Python

```python
import os, requests

res = requests.get(
    "https://api.threadapi.dev/v1/reddit/subreddit/posts",
    headers={"Authorization": f"Bearer {os.environ['THREADAPI_API_KEY']}"},
    params={
        "sub": "golang",
        "sort": "new",
        "limit": 100,
        "after": "t3_1x0vbyx",
    },
)
res.raise_for_status()
page = res.json()
print(f"Got {page['count']} posts; next page after: {page['after']}")
```

### TypeScript

```ts
const params = new URLSearchParams({
  sub: "golang",
  sort: "new",
  limit: "100",
  after: "t3_1x0vbyx",
});
const res = await fetch(`https://api.threadapi.dev/v1/reddit/subreddit/posts?${params}`, {
  headers: { Authorization: `Bearer ${process.env.THREADAPI_API_KEY}` },
});
const page = await res.json();
console.log(`Got ${page.count} posts; next page after: ${page.after}`);
```

`after` is a Reddit fullname (`t3_…` for posts, `t1_…` for comments) except on comment search, where it is an opaque string. Treat it as opaque everywhere and pass it back unchanged.

Reddit stops a listing at about 1,000 items, whatever the sort. To go further back, narrow the request: a shorter `t` window, a search with `sub`, or a different sort.

## NSFW

Items Reddit marks NSFW are left out unless you pass `nsfw=true`. `filtered_nsfw` counts how many were left out of the page, so a page can hold fewer than `limit` items while `after` is still set.

Reading a subreddit that is itself marked NSFW without `nsfw=true` returns 403 `nsfw_subreddit`:

```json
{"error":{"code":"nsfw_subreddit","message":"This subreddit is marked NSFW. Pass nsfw=true to read it.","retryable":false}}
```

## Caching

Listings are cached briefly: 30 seconds for `new` and `rising`, a minute for `hot` and search, and 5 minutes for `top` and `controversial` over a day or longer. The `X-Cache` header says whether the page came from the cache (`HIT`) or from Reddit (`MISS`). A cached page costs the same 1 credit.

Source: https://threadapi.dev/docs/listings/index.mdx
