# Search posts

Searches posts.

```http
GET https://api.pozy.ai/v1/reddit/search
```

- Area: Inbox / Reddit Search
- Auth: Authorization: Bearer pz_live_...

## Query parameters

- `accountId` (string, required)
- `subreddit` (string)
- `q` (string, required)
- `restrict_sr` (string): one of 0, 1
- `sort` (string): one of relevance, hot, top, new, comments
- `limit` (integer)
- `after` (string)

## Example request

```bash
curl -X GET "https://api.pozy.ai/v1/reddit/search?accountId=696e0b682d0a31188e7a2ba9&q=string&limit=25" \
  -H "Authorization: Bearer $POZY_API_KEY"
```

```ts
const res = await fetch("https://api.pozy.ai/v1/reddit/search?accountId=696e0b682d0a31188e7a2ba9&q=string&limit=25", {
  headers: { Authorization: `Bearer ${process.env.POZY_API_KEY}` },
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.get(
    "https://api.pozy.ai/v1/reddit/search",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    params={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "q": "string",
        "limit": 25,
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `items`, array of object
  - `id`, string
  - `fullname`, string
  - `title`, string
  - `author`, string
  - `subreddit`, string
  - `url`, string
  - `permalink`, string
  - `selftext`, string
  - `createdUtc`, number
  - `score`, integer
  - `numComments`, integer
  - `over18`, boolean
  - `stickied`, boolean
  - `flairText`, string: Can be null
  - `isGallery`, boolean
  - `galleryImages`, array of string (URL)
- `after`, string: Can be null
- `before`, string: Can be null

```json
{
  "items": [
    {
      "id": "6bfebd43ddc270f6d2c56fc5",
      "fullname": "Acme",
      "title": "Launch day",
      "author": "string",
      "subreddit": "string",
      "url": "https://pozy.ai/media/example-1.jpg",
      "permalink": "string",
      "selftext": "Hello from Pozy",
      "createdUtc": 12.5,
      "score": 1,
      "numComments": 1,
      "over18": true,
      "stickied": true,
      "flairText": "Hello from Pozy",
      "isGallery": true,
      "galleryImages": [
        "https://pozy.ai/media/example-1.jpg"
      ]
    }
  ],
  "after": "string",
  "before": "string"
}
```
