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

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
{
  "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

I