---
title: "Getting started"
description: "Create an account, get an API key and make your first API call to read Reddit."
---

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

# Getting started

ThreadAPI provides real-time access to Reddit posts, comments, subreddits, and user profiles as clean JSON or LLM-ready Markdown.

## 1. Create an account and get an API key

1. Open the [ThreadAPI Console](https://app.threadapi.dev).
2. Sign in with your email address using a one-time code or OAuth. New accounts receive free trial credits.
3. In the console, navigate to **[API Keys](https://app.threadapi.dev/api-keys)** and click **Create Key**.
4. Copy your key immediately (starts with `tapi_`). It is only shown once.

> **Keep your API key private**
>
> Your API key grants access to your credit balance. Always store it in environment variables on your backend or CLI tool, never in public repositories or client-side code.

## 2. Make your first API call

Pass your API key in the `Authorization` header as a Bearer token:

### Example: Read subreddit information

### cURL

```bash
curl -X GET "https://api.threadapi.dev/v1/reddit/subreddit?sub=selfhosted" \
  -H "Authorization: Bearer $THREADAPI_API_KEY"
```

### Python

```python
import os, requests

res = requests.get(
    "https://api.threadapi.dev/v1/reddit/subreddit",
    headers={"Authorization": f"Bearer {os.environ['THREADAPI_API_KEY']}"},
    params={"sub": "selfhosted"},
)
res.raise_for_status()
sub = res.json()
print(sub["name"], "-", sub["title"])
print(f"Subscribers: {sub['subscribers']:,}")
```

### TypeScript

```ts
const res = await fetch("https://api.threadapi.dev/v1/reddit/subreddit?sub=selfhosted", {
  headers: { Authorization: `Bearer ${process.env.THREADAPI_API_KEY}` },
});
const sub = await res.json();
console.log(`${sub.name} - ${sub.title} (${sub.subscribers} subscribers)`);
```

Response:

```json
{
  "name": "selfhosted",
  "title": "Self-Hosted Alternatives to Popular Services",
  "public_description": "A place to share, discuss, discover, assist with, gain assistance for, and critique self-hosted alternatives...",
  "subscribers": 868722,
  "created_at": "2014-07-08T09:34:14.239Z",
  "is_nsfw": false,
  "type": "public",
  "url": "/r/selfhosted/",
  "icon": "https://styles.redditmedia.com/t5_32hch/styles/communityIcon_zttnt3jjmddh1.png?width=64&frame=1&auto=webp&s=4a0dfbfac29b79ce75d06e5079e027aad47a849b",
  "rules": [
    {
      "priority": 0,
      "short_name": "Low-Effort / Off-Topic",
      "description": "All posts must be about self-hosting...",
      "violation_reason": "Low-Effort / Off-Topic (Not Selfhosted)"
    }
  ]
}
```

### Example: Fetch a post and comment tree

### cURL

```bash
curl -X GET "https://api.threadapi.dev/v1/reddit/post?url=https://www.reddit.com/r/selfhosted/comments/1sey9ch/&format=json" \
  -H "Authorization: Bearer $THREADAPI_API_KEY"
```

### Python

```python
import os, requests

res = requests.get(
    "https://api.threadapi.dev/v1/reddit/post",
    headers={"Authorization": f"Bearer {os.environ['THREADAPI_API_KEY']}"},
    params={
        "url": "https://www.reddit.com/r/selfhosted/comments/1sey9ch/",
        "format": "json",
    },
)
res.raise_for_status()
data = res.json()
print(data["post"]["title"])
print(f"Comments returned: {data['meta']['comments_returned']}/{data['post']['comments_count']}")
```

### TypeScript

```ts
const params = new URLSearchParams({
  url: "https://www.reddit.com/r/selfhosted/comments/1sey9ch/",
  format: "json",
});
const res = await fetch(`https://api.threadapi.dev/v1/reddit/post?${params}`, {
  headers: { Authorization: `Bearer ${process.env.THREADAPI_API_KEY}` },
});
const data = await res.json();
console.log(`${data.post.title} (${data.meta.comments_returned} comments)`);
```

To receive a clean, structured Markdown digest instead of JSON, pass `format=md`:

### cURL

```bash
curl -X GET "https://api.threadapi.dev/v1/reddit/post?url=https://www.reddit.com/r/selfhosted/comments/1sey9ch/&format=md" \
  -H "Authorization: Bearer $THREADAPI_API_KEY"
```

### Python

```python
import os, requests

res = requests.get(
    "https://api.threadapi.dev/v1/reddit/post",
    headers={"Authorization": f"Bearer {os.environ['THREADAPI_API_KEY']}"},
    params={
        "url": "https://www.reddit.com/r/selfhosted/comments/1sey9ch/",
        "format": "md",
    },
)
res.raise_for_status()
print(res.text)  # Plain markdown with indented discussion tree
```

### TypeScript

```ts
const params = new URLSearchParams({
  url: "https://www.reddit.com/r/selfhosted/comments/1sey9ch/",
  format: "md",
});
const res = await fetch(`https://api.threadapi.dev/v1/reddit/post?${params}`, {
  headers: { Authorization: `Bearer ${process.env.THREADAPI_API_KEY}` },
});
const markdown = await res.text();
console.log(markdown);
```

## 3. Rate limits & billing

* **Credits**: Standard listing and post requests cost **1 credit**. Deep comment trees cost 1 credit per 500 comments.
* **Response headers**: Every response returns `X-Credits-Used`, `X-Cache` (`HIT` or `MISS`), and `X-Request-Id`.
* **Zero charge on failure**: Requests resulting in 4xx or 5xx errors are never billed.
* **Top up**: Purchase non-expiring credit packs anytime in the **[Billing Console](https://app.threadapi.dev/billing)**.

## 4. Next steps

* **[Interactive Playground](https://app.threadapi.dev/playground)**: Test every endpoint directly in your browser.
* **[API Reference](/api/)**: Explore full OpenAPI specifications and interactive curl builders for all endpoints.
* **[MCP Server](/docs/mcp)**: Connect Claude, Cursor, VS Code, or Codex to real-time Reddit data via MCP.
* **[Keyword Monitors](/docs/monitors)**: Stream new Reddit posts and comments matching your keywords to webhooks or Discord.

Source: https://threadapi.dev/docs/getting-started/index.mdx
