Discourse Search API
The Search API from Discourse — 1 operation(s) for search.
The Search API from Discourse — 1 operation(s) for search.
openapi: 3.1.0
info:
title: Discourse API Documentation Admin Search API
x-logo:
url: https://docs.discourse.org/logo.svg
version: latest
description: 'This page contains the documentation on how to use Discourse through API calls.
> Note: For any endpoints not listed you can follow the
[reverse engineer the Discourse API](https://meta.discourse.org/t/-/20576)
guide to figure out how to use an API endpoint.
### Request Content-Type
The Content-Type for POST and PUT requests can be set to `application/x-www-form-urlencoded`,
`multipart/form-data`, or `application/json`.
### Endpoint Names and Response Content-Type
Most API endpoints provide the same content as their HTML counterparts. For example
the URL `/categories` serves a list of categories, the `/categories.json` API provides the
same information in JSON format.
Instead of sending API requests to `/categories.json` you may also send them to `/categories`
and add an `Accept: application/json` header to the request to get the JSON response.
Sending requests with the `Accept` header is necessary if you want to use URLs
for related endpoints returned by the API, such as pagination URLs.
These URLs are returned without the `.json` prefix so you need to add the header in
order to get the correct response format.
### Authentication
Some endpoints do not require any authentication, pretty much anything else will
require you to be authenticated.
To become authenticated you will need to create an API Key from the admin panel.
Once you have your API Key you can pass it in along with your API Username
as an HTTP header like this:
```
curl -X GET "http://127.0.0.1:3000/admin/users/list/active.json" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system"
```
and this is how POST requests will look:
```
curl -X POST "http://127.0.0.1:3000/categories" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system" \
-F "name=89853c20-4409-e91a-a8ea-f6cdff96aaaa" \
-F "color=49d9e9" \
-F "text_color=f0fcfd"
```
### Boolean values
If an endpoint accepts a boolean be sure to specify it as a lowercase
`true` or `false` value unless noted otherwise.
'
license:
name: MIT
url: https://docs.discourse.org/LICENSE.txt
servers:
- url: https://{defaultHost}
variables:
defaultHost:
default: discourse.example.com
tags:
- name: Search
paths:
/search.json:
get:
summary: Search for a term
tags:
- Search
operationId: search
parameters:
- name: q
in: query
example: 'api @blake #support tags:api after:2021-06-04 in:unseen in:open
order:latest_topic'
description: '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:4200/search.json" \
--data-urlencode ''q=wordpress @scossar #fun after:2020-01-01''
```
'
schema:
type: string
- name: page
in: query
example: 1
schema:
type: integer
responses:
'200':
description: success response
content:
application/json:
schema:
additionalProperties: false
properties:
posts:
type: array
items: {}
users:
type: array
items: {}
categories:
type: array
items: {}
tags:
type: array
items:
type: object
properties:
id:
type: integer
name:
type: string
slug:
type: string
required:
- id
- name
- slug
groups:
type: array
items: {}
grouped_search_result:
type: object
additionalProperties: false
properties:
more_posts:
type:
- string
- 'null'
more_users:
type:
- string
- 'null'
more_categories:
type:
- string
- 'null'
term:
type: string
search_log_id:
type: integer
more_full_page_results:
type:
- string
- 'null'
can_create_topic:
type: boolean
error:
type:
- string
- 'null'
extra:
type: object
properties:
categories:
type:
- array
- 'null'
post_ids:
type: array
items: {}
user_ids:
type: array
items: {}
category_ids:
type: array
items: {}
tag_ids:
type: array
items: {}
group_ids:
type: array
items: {}
required:
- more_posts
- more_users
- more_categories
- term
- search_log_id
- more_full_page_results
- can_create_topic
- error
- post_ids
- user_ids
- category_ids
- tag_ids
- group_ids
required:
- posts
- users
- categories
- tags
- groups
- grouped_search_result