# Knowledge Base Search API
# Overview
This API endpoint allows you to search through articles and other content with semantic understanding. It returns results ranked by relevance to your query. Other than the External Knowledge API, this API searches all of your knowledge, including Webpages, PDFs, (internal/external) Articles, Q&A or tables.
# Authentication
- All endpoints require API key authentication, ask your Customer Success Manager or techical support at moinAI for the key.
Example `cURL' call:
curl -L 'https://api.moin.ai/api/v1/knowledge/search' -H 'Content-Type: application/json' -H 'x-api-key: YOUR_API_KEY' -d '{"query":"Was ist der Punktprozess?","options":{"topK":5,"includeContent":true,"includeFaqs":false},"filters":{"type":"WEBPAGE"}}'
Beware: If your company owns more than one chatbot from moinAI, then each of the bots has a single dedicated API key that identifies the bot where the knowledge should be added.
# Endpoint: Search for knowledge that is related to a query
- Method: POST
- Endpoint:
https://api.moin.ai/api/v1/knowledge/search
# Request Body
Field | Type | Required | Description |
---|---|---|---|
query | string | Yes | The search query text |
filters | object | No | Optional filters to narrow search results |
options | object | No | Optional configuration for the search |
# Options Object
Field | Type | Description |
---|---|---|
topK | number | Limit the number of results returned |
includeFaqs | boolean | Whether to include FAQ content in results |
includeContent | boolean | Whether to include full content in response |
onlyActiveIntents | boolean | Whether to only return active intent matches |
# Example Request body:
{
"query": "Was ist ein Punktprozess?",
"options": {
"topK": 5,
"includeContent": true,
"includeFaqs": false
},
"filters": {
"type": "WEBPAGE"
}
}
# Response
The API returns an array of matching documents, each containing:
Field | Type | Description |
---|---|---|
resourceDocId | string | Unique identifier for the document |
type | string | Document type (WEBPAGE, PDF, DOCUMENT, or IMAGE) |
status | string | Document status (active, inactive, or pending) |
metaData | object | Additional metadata about the document |
url | string | URL of the resource (if applicable) |
bestMatchScore | number | Highest similarity score (0-1) among matched text parts |
similarTextParts | array | Text segments that match the query with similarity scores |
content | array | Content blocks of the document |
# Similar Text Parts Object
Field | Type | Description |
---|---|---|
text | string | The matched text content |
similarity | number | Similarity score (0-1) where 1 indicates perfect match |
start | integer | Starting position (line) of the matched text |
stop | integer | Ending position (line) of the matched text |
# Content Object
Field | Type | Description |
---|---|---|
md | string | Markdown content of the resource |
# Example response:
[
{
"resourceDocId": "667970c04f8d423fa368a549",
"type": "WEBPAGE",
"status": "active",
"metaData": {},
"url": "https://de.wikipedia.org/wiki/Punktprozess",
"similarTextParts": [
{
"text": "Some text part of the whole content",
"similarity": 0.8876120515100941,
"start": 5,
"stop": 12
},
{
"text": "Another text part of the whole content",
"similarity": 0.8796765947727511,
"start": 34,
"stop": 43
}
],
"bestMatchScore": 0.8876120515100941,
"content": [
{
"md": "The whole content of the webpage"
}
]
}
]
# Example Usage
JavaScript:
const response = await fetch('https://api.moin.ai/api/v1/knowledge/search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key: YOUR_API_KEY'
},
body: JSON.stringify({
query: "How do I reset my password?",
options: {
topK: 5,
includeFaqs: true
}
})
});
const results = await response.json();
Python:
import requests
import json
url = "https://api.moin.ai/api/v1/knowledge/search"
headers = {
"Content-Type": "application/json",
"x-api-key": "YOUR_API_KEY"
}
payload = {
"query": "How do I reset my password?",
"options": {
"topK": 5,
"includeFaqs": True
}
}
response = requests.post(url, headers=headers, json=payload)
results = response.json()