Query semantic entries¶
Lists business definition entries in the knowledge base in pages.
GET https://moi.matrixorigin.cn/newmoi/semantic-models/{model_id}/entries
Preparation before calling¶
First query the knowledge base list to obtain the knowledge base ID. Prepare a personal access token and target workspace ID that has access to the target workspace.
The example below uses:
$AI_STUDIO_API_KEY: The actual personal access token, passed through theX-API-KeyHeader.$WORKSPACE_ID: Target workspace ID, passed throughX-Workspace-IDHeader.$MODEL_ID: ID of the knowledge base to be queried.
Request example¶
curl "https://moi.matrixorigin.cn/newmoi/semantic-models/$MODEL_ID/entries?kind=metric&page_size=20" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID"
Path parameters¶
Parameters |
Type |
Description |
|---|---|---|
|
integer |
Knowledge base ID. |
Query parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
No |
Entry type filter criteria; available values and their configuration fields can be found in Create Semantic Entry. |
|
integer |
No |
The number of items in a single page, ranging from |
|
string |
No |
|
Successful response¶
Returns 200 on success. Save data.items[].id and use it for subsequent update and deletion interfaces.
{
"code": "OK",
"msg": "OK",
"data": {
"items": [
{
"id": 501,
"kind": "metric",
"key": "total_rows",
"tables": ["orders"],
"spec": {
"expr": "COUNT(*)"
},
"created_at": 1735632000,
"updated_at": 1735632000
}
],
"total": 1,
"next_page_token": ""
}
}
The response fields are as follows.
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object[] |
The semantic entry of the current page. |
|
integer |
Entry ID. |
|
string |
Entry type. |
|
string |
Stable reference key within the knowledge base. |
|
array[string] |
Association table name; may be omitted if not set. |
|
object |
Type-specific configuration object corresponding to |
|
integer |
Creation time as a Unix timestamp. |
|
integer |
Update time as a Unix timestamp. |
|
integer |
The total number of entries matching the filter criteria. |
|
string |
Next page token; if empty, there is no next page. |
In field paths, [] means each item in an array. For example, data.items[].id is the id field of each item in data.items.
Read next page¶
When data.next_page_token in the response is not empty, it is passed to the next page request as page_token; when it is empty, it means that the last page has been read.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "page_size is invalid",
"data": null
}
Common HTTP errors¶
HTTP status code |
error code |
Common causes |
Recommended actions |
|---|---|---|---|
|
|
|
Correct the parameters and try again. |
|
|
The API Key is invalid or has expired. |
Check API Key. |
|
|
The caller does not have read permission. |
Check workspace and object authorization. |
|
|
The knowledge base does not exist or is not visible. |
Reconfirm |
|
|
The service failed to read the entry. |
Keep the desensitized response information and try again. |
Follow-up operations¶
When you need to add a new one, Create semantic entries; after selecting an existing entry, you can Update semantic entries or Delete semantic entries.