MedicalKnow - Health knowledge graph API
Call the MedicalKnow API to retrieve structured knowledge about medical entities and their attributes, based on authoritative data.
API
API name: MedicalKnow
Capabilities:
Based on authoritative medical data, this API performs attribute queries on medical entities such as "Amoxicillin Capsules", "Aspirin", "calories in an apple", and "hypertension". It provides more comprehensive medical information than standard search APIs.
The API returns structured text that describes an entity and its attributes, making it an ideal knowledge base for drugs, medical conditions, and food. The API does not support subjective or recommendation-based questions, such as "which brand is better?". For these questions, use the Medical Q&A API instead. If a query is unsupported, the API returns an empty
messagesarray.
This service is billed on a pay-per-use basis as a vertical search. For pricing, see Vertical Query - Billing Details.
The server-side timeout is 5 seconds.
The health and medical content provided by this service is for informational purposes only. It is not a substitute for professional medical advice, diagnosis, or treatment from a qualified physician.
API reference
Request parameters
Parameter | Type | Required | Default | Description | Example value |
query | string | Yes | - | The search query. The query must be 1–200 characters long. For best results, keep the query under 30 characters. You can use a model on the client side to rewrite longer queries before calling the API. | Amoxicillin Capsules |
type | string | No | - | The query type. This parameter narrows the scope of entity recognition. Valid values: | medicine |
Response parameters
Field | Type | Nullable | Description | Example |
requestId | string | No | The request ID. Provide this ID when you contact technical support to troubleshoot an issue. | 35E5608A-A737-2038-****-D9D34C6BFD9E |
messages | list | Yes | A list of results containing entity attributes. This field returns an empty array if no entity is identified, for example, if the query is empty, the type does not match, or the query is not an entity. Your application must implement a fallback for empty results. | See the example below. |
messages[].content | string | No | The content, formatted as structured text. It starts with "Entity: X", followed by one or more attribute lines in the format "- Attribute[AttributeName]: AttributeValue". Each item is separated by a newline character. The number of attributes varies by entity, typically from one to seven. | Entity: Amoxicillin Capsules\n- Attribute[Precise Active Ingredient]: Amoxicillin\n- Attribute[Dosage Form]: Oral capsule... |
messages[].url | string | No | The URL of the content source. | https://p.example.cn/0387f345/index?struct_id=... |
searchInformation.searchTime | int64 | No | The search time in milliseconds. | 308 |
queryContext.originalQuery.query | string | No | Echoes the original query from the request. | Amoxicillin Capsules |
Examples
Request body
{
"query": "Amoxicillin Capsules",
"type": "medicine"
}Response body
{
"requestId": "d3c1b3*********cdebe",
"messages": [
{
"url": "https://p.example.cn/0387f345/index?struct_id=VdB%2BLV7w7lHHEp",
"content": "Entity: Amoxicillin Capsules\n- Attribute[Precise Active Ingredient]: Amoxicillin\n- Attribute[Dosage Form]: Oral capsule\n- Attribute[Indications]: Amoxicillin is a penicillin antibiotic that has a strong bactericidal effect...\n- Attribute[Pharmacological Action]: Amoxicillin exerts its bactericidal effect by inhibiting the synthesis of bacterial cell walls."
}
],
"searchInformation": {
"searchTime": 308
},
"queryContext": {
"originalQuery": {
"query": "Amoxicillin Capsules"
}
}
}Call the API
Authenticate your requests by using your product credential (API key). You can create an API key in the console under "Create/View Credential Key". After you create an API key, allow about 5 minutes for it to take effect.
curl -X POST https://cloud-iqs.aliyuncs.com/medical/know \
--header "Authorization: Bearer $API_KEY" \
--header "Content-Type: application/json" \
--data '{
"query": "Amoxicillin Capsules",
"type": "medicine"
}'This API supports direct HTTP calls only and is not available through the Alibaba Cloud OpenAPI SDK.
Error codes
If a request fails, the API returns a non-2xx HTTP status code and a response body with a flat structure. The errorCode and errorMessage fields are always returned. Some errors might also include code and message fields with the same meaning. When you parse an error response, use the errorCode field as the definitive source.
{
"errorCode": "Retrieval.EngineNotActivate",
"errorMessage": "Please activate medicalKnowSearch.",
"code": "Retrieval.EngineNotActivate",
"message": "Please activate medicalKnowSearch."
}Status | Error code | Error message | Solution |
403 | Retrieval.InvalidAPIKey | Incorrect API key provided. | Verify that the Authorization header is in the |
403 | Retrieval.EngineNotActivate | Please activate medicalKnowSearch. | The |
403 | Retrieval.NotActivate | Please activate AI search service | Subscribe to the service or contact your account manager to activate it. |
403 | Retrieval.Arrears | Please recharge first. | Your account has an insufficient balance. Please add funds to your account. |
403 | Retrieval.NotAuthorised | Please authorize the AliyunIQSFullAccess privilege to the sub-account. | The sub-account does not have the required permissions. See "Create a RAM user and grant permissions". |
403 | Retrieval.TestUserPeriodExpired | The test period has expired. | The trial period has expired. The trial is valid for 15 days after you subscribe. Contact your Alibaba Cloud account manager to upgrade to a paid plan. |
429 | Retrieval.Throttling.User | Request was denied due to user flow control. | The request rate has exceeded your service limit. Contact your Alibaba Cloud account manager to upgrade your plan. |
429 | Retrieval.TestUserQueryExceeded | The query exceeds the limit | The number of queries has exceeded the daily limit for trial users (1,000 queries per day). Contact your Alibaba Cloud account manager to upgrade to a paid plan. |
500 | InternalServerError | An unexpected error occurred | An internal service error occurred. First, ensure that the |