Skip to content
StudyFetch API

Materials

Search materials using RAG (Retrieval-Augmented Generation)

OpenAPI specification
POST/api/v1/materials/search

Authentication

x-api-key

Request

curl --globoff --request POST \
  --url 'https://api.example.com/api/v1/materials/search' \
  --header 'x-api-key: <API_KEY>' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "query": "What is photosynthesis?"
}'

Replace credential and <field> placeholders with your own values. URL placeholders appear as %3Cfield%3E. Review the example values before sending your request.

Replace https://api.example.com with the API server URL.

Use the sample JSON body as your starting point, and enter values that match the endpoint's schema.

Request body schema or example

{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "example": "What is photosynthesis?",
      "description": "Search query"
    },
    "topK": {
      "type": "number",
      "default": 5,
      "description": "Number of results to return"
    },
    "materialIds": {
      "description": "Limit search to specific material IDs",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "folderIds": {
      "description": "Limit search to materials within specific folders (includes subfolders)",
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "query"
  ]
}

Responses

200Search completed successfully
{
  "type": "object",
  "properties": {
    "query": {
      "type": "string",
      "description": "Original search query"
    },
    "results": {
      "description": "Search results",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "score": {
            "type": "number",
            "description": "Relevance score (0-1)"
          },
          "text": {
            "type": "string",
            "description": "Matched text chunk"
          },
          "chunkIndex": {
            "type": "number",
            "description": "Chunk index within the material"
          },
          "material": {
            "type": "object",
            "description": "Material information",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "score",
          "text",
          "chunkIndex",
          "material"
        ]
      }
    },
    "totalResults": {
      "type": "number",
      "description": "Total number of results"
    },
    "filtered": {
      "type": "boolean",
      "description": "Whether results were filtered by scope"
    },
    "scope": {
      "type": "object",
      "description": "Search scope",
      "properties": {
        "materialIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "folderIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  },
  "required": [
    "query",
    "results",
    "totalResults",
    "filtered",
    "scope"
  ]
}
400Invalid query
404Folder not found (if folder filter used)