# Search for a term

`GET /search.json`

Authentication: no security requirement declared for this operation.

Parameters:

- `q` (query, string, optional) - The query string needs to be url encoded and is made up of the following options:
- Search term. This is just a string. Usually it would be the first item in the query.
- `@<username>`: Use the `@` followed by the username to specify posts by this user.
- `#<category>`: Use the `#` followed by the category slug to search within this category.
- `tags:`: `api,solved` or for posts that have all the specified tags `api+solved`.
- `before:`: `yyyy-mm-dd`
- `after:`: `yyyy-mm-dd`
- `order:`: `latest`, `likes`, `views`, `latest_topic`
- `assigned:`: username (without `@`)
- `in:`: `title`, `likes`, `personal`, `messages`, `seen`, `unseen`, `posted`, `created`, `watching`, `tracking`, `bookmarks`, `assigned`, `unassigned`, `first`, `pinned`, `wiki`
- `with:`: `images`
- `status:`: `open`, `closed`, `public`, `archived`, `noreplies`, `single_user`, `solved`, `unsolved`
- `group:`: group_name or group_id
- `group_messages:`: group_name or group_id
- `min_posts:`: 1
- `max_posts:`: 10
- `min_views:`: 1
- `max_views:`: 10

If you are using cURL you can use the `-G` and the `--data-urlencode` flags to encode the query:

```
curl -i -sS -X GET -G "http://localhost:3000/search.json" \
--data-urlencode 'q=wordpress @scossar #fun after:2020-01-01'
```

  Type: string

- `page` (query, integer, optional)
  Type: integer

Responses:

- 200: success response

Content type: application/json

Type: any

- `posts` (required)
  Type: Array<any>
  
  Items:
    Type: any

- `users` (required)
  Type: Array<any>
  
  Items:
    Type: any

- `categories` (required)
  Type: Array<any>
  
  Items:
    Type: any

- `tags` (required)
  Type: Array<object>
  
  Items:
    Type: object
    
    - `id` (required)
      Type: integer
    
    - `name` (required)
      Type: string
    
    - `slug` (required)
      Type: string

- `groups` (required)
  Type: Array<any>
  
  Items:
    Type: any

- `grouped_search_result` (required)
  Type: object
  
  - `more_posts` (required)
    Type: string; nullable
  
  - `more_users` (required)
    Type: string; nullable
  
  - `more_categories` (required)
    Type: string; nullable
  
  - `term` (required)
    Type: string
  
  - `search_log_id` (required)
    Type: integer
  
  - `more_full_page_results` (required)
    Type: string; nullable
  
  - `can_create_topic` (required)
    Type: boolean
  
  - `error` (required)
    Type: string; nullable
  
  - `extra` (optional)
    Type: object
    
    - `categories` (optional)
      Type: array; nullable
  
  - `post_ids` (required)
    Type: Array<any>
    
    Items:
      Type: any
  
  - `user_ids` (required)
    Type: Array<any>
    
    Items:
      Type: any
  
  - `category_ids` (required)
    Type: Array<any>
    
    Items:
      Type: any
  
  - `tag_ids` (required)
    Type: Array<any>
    
    Items:
      Type: any
  
  - `group_ids` (required)
    Type: Array<any>
    
    Items:
      Type: any
  
  Additional properties: false

Additional properties: false

## Examples

### cURL

```bash
curl -X GET 'https://discourse.example.com/search.json?q=api%20%40blake%20%23support%20tags%3Aapi%20after%3A2021-06-04%20in%3Aunseen%20in%3Aopen%0Aorder%3Alatest_topic&page=1'
```

### JavaScript

```javascript
const response = await fetch('https://discourse.example.com/search.json?q=api%20%40blake%20%23support%20tags%3Aapi%20after%3A2021-06-04%20in%3Aunseen%20in%3Aopen%0Aorder%3Alatest_topic&page=1', {
  method: 'GET',
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get('https://discourse.example.com/search.json?q=api%20%40blake%20%23support%20tags%3Aapi%20after%3A2021-06-04%20in%3Aunseen%20in%3Aopen%0Aorder%3Alatest_topic&page=1')
print(response.text)
```
