Knowledge Base

Get Knowledgebase File

Get file information in one of two ways: pass file_ids to retrieve specific file details, or pass knowledgebase_id to list files under a Knowledge Base. Choose only one mode; passing both knowledgebase_id and file_ids returns an error.

POST
/
get
/
knowledgebase-file
import os
import requests
import json

# Replace with your API Key
os.environ["MEMOS_API_KEY"] = "YOUR_API_KEY"
os.environ["MEMOS_BASE_URL"] = "https://memos.memtensor.cn/api/openmem/v1"

data = {
  "knowledgebase_id": "kb_xxx",  # List files under this Knowledge Base
  "type": "skill",               # Optional: document / skill
  "page": 1,
  "page_size": 20
}
headers = {
  "Content-Type": "application/json",
  "Authorization": f"Token {os.environ['MEMOS_API_KEY']}"
}
url = f"{os.environ['MEMOS_BASE_URL']}/get/knowledgebase-file"

res = requests.post(url=url, headers=headers, data=json.dumps(data))

print(f"result: {res.json()}")
{
  "code": 0,
  "data": {
    "total": 0,
    "page": 0,
    "page_size": 0,
    "file_detail_list": [
      {
        "id": "<string>",
        "type": "document",
        "name": "<string>",
        "size": "<string>",
        "status": "running"
      }
    ]
  },
  "message": "<string>"
}

Authorizations

Authorization
string
header
required

Token API_key, available in API Console > API Keys

Body

application/json
knowledgebase_id
string
Query mode 1: target Knowledge Base ID. Returns files under the Knowledge Base and can be used with type, page, and page_size. Do not pass it together with file_ids.
type
string
File type filter, effective only when querying by knowledgebase_id. document returns only ordinary documents; skill returns only Skill files; omit this field to return all files. Do not use it with the file_ids query mode.
Enum:"document""skill"
page
number
default: 1
Page number, effective only when querying by knowledgebase_id. Do not use it with the file_ids query mode.
page_size
number
default: 20
Items per page, effective only when querying by knowledgebase_id. Do not use it with the file_ids query mode.
file_ids
string[]
Query mode 2: file ID list. Returns details for the specified files. When using this mode, pass only file_ids and do not pass knowledgebase_id, type, page, or page_size.

Response

application/json

Successful Response

code
number
required

API status code. See Error Code for details.

data
object
Show child attributes
message
string
required

API response message