Skip to main content
POST
/
api
/
v1
/
materials
/
search
Search for materials
const options = {
  method: 'POST',
  headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    query: 'What is photosynthesis?',
    topK: 5,
    materialIds: ['<string>'],
    folderIds: ['<string>']
  })
};

fetch('https://studyfetchapi.com/api/v1/materials/search', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "query": "<string>",
  "results": [
    {
      "score": 123,
      "text": "<string>",
      "chunkIndex": 123,
      "material": {
        "id": "<string>",
        "name": "<string>",
        "contentType": "<string>"
      }
    }
  ],
  "totalResults": 123,
  "filtered": true,
  "scope": {
    "materialIds": [
      "<string>"
    ],
    "folderIds": [
      "<string>"
    ]
  }
}

Authorizations

x-api-key
string
header
required

API Key for authentication

Body

application/json
query
string
required

Search query

Example:

"What is photosynthesis?"

topK
number
default:5

Number of results to return

materialIds
string[]

Limit search to specific material IDs

folderIds
string[]

Limit search to materials within specific folders (includes subfolders)

Response

Search completed successfully

query
string
required

Original search query

results
object[]
required

Search results

totalResults
number
required

Total number of results

filtered
boolean
required

Whether results were filtered by scope

scope
object
required

Search scope