GitBook API API ReferenceSearch Configure and manage search settings for your content.
Search content in a space
get
https://api.gitbook.com/v1 /spaces/ {spaceId} /search
spaceId string required
The unique id of the space
query string · max: 512 required
page string
Identifier of the page results to fetch.
limit number · max: 1000
The number of results per page
Copy curl -L \
--url 'https://api.gitbook.com/v1/spaces/{spaceId}/search?query=text' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Copy {
"next": {
"page": "text"
},
"count": 1,
"items": [
{
"id": "text",
"title": "text",
"path": "text",
"sections": [
{
"id": "text",
"title": "text",
"path": "text",
"body": "text",
"urls": {
"app": "https://example.com"
}
}
],
"urls": {
"app": "https://example.com"
}
}
]
}
Ask a question.
post
https://api.gitbook.com/v1 /orgs/ {organizationId} /ask
organizationId string required
The unique id of the organization
format string · enum
Output format for the content.
Options: document
, markdown
details boolean
Return query details in the result
previousQueries string[] · max: 10 Deprecated
Copy curl -L \
--request POST \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"query": "text",
"previousQueries": [
"text"
]
}'
Copy {
"answer": {
"answer": {
"markdown": "text"
},
"followupQuestions": [
"text"
],
"sources": [
{
"type": "page",
"reason": "text",
"page": "text",
"revision": "text",
"space": "text",
"sections": [
"text"
]
}
]
}
}
Get a list of questions recommended to be asked in an organization.
get
https://api.gitbook.com/v1 /orgs/ {organizationId} /ask/questions
organizationId string required
The unique id of the organization
Copy curl -L \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask/questions' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Copy {
"questions": [
"text"
]
}
Stream a list of questions recommended to be asked in an organization.
get
https://api.gitbook.com/v1 /orgs/ {organizationId} /ask/questions/stream
organizationId string required
The unique id of the organization
Copy curl -L \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask/questions/stream' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Copy {
"question": "text"
}
Ask a question to an AI across spaces that is accessible by the currently authenticated target and stream the answer as a Server-Sent Events URL.
get
https://api.gitbook.com/v1 /orgs/ {organizationId} /ask/stream
organizationId string required
The unique id of the organization
format string · enum
Output format for the content.
Options: document
, markdown
details boolean
Return query details in the result
Copy curl -L \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/ask/stream?query=text' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Copy {
"type": "answer",
"answer": {
"answer": {
"markdown": "text"
},
"followupQuestions": [
"text"
],
"sources": [
{
"type": "page",
"reason": "text",
"page": "text",
"revision": "text",
"space": "text",
"sections": [
"text"
]
}
]
}
}
Ask a question in a site. The response is streamed.
post
https://api.gitbook.com/v1 /orgs/ {organizationId} /sites/ {siteId} /ask
organizationId string required
The unique id of the organization
siteId string required
The unique id of the site
format string · enum
Output format for the content.
Options: document
, markdown
question string · max: 512 required
context object
You may optionally provide additional information about the context of the question. This doesn't affect the scope of the search, but GitBook may use this information to provide a better answer. Generally speaking, you should provide as much context as possible.
Copy curl -L \
--request POST \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/ask' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"question": "text",
"context": {
"siteSpaceId": "text"
},
"scope": {
"mode": "default",
"includedSiteSpaces": [
"text"
]
}
}'
Copy {
"type": "answer",
"answer": {
"answer": {
"markdown": "text"
},
"followupQuestions": [
"text"
],
"sources": [
{
"type": "page",
"reason": "text",
"page": "text",
"revision": "text",
"space": "text",
"sections": [
"text"
]
}
]
}
}
Stream a list of questions that can be asked in a site.
get
https://api.gitbook.com/v1 /orgs/ {organizationId} /sites/ {siteId} /ask/questions
organizationId string required
The unique id of the organization
siteId string required
The unique id of the site
Copy curl -L \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/sites/{siteId}/ask/questions' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Copy {
"question": "text"
}