Smart Question Search API
CleverSee - Smart Question Search API
Use the searchQuestion API to search for questions by text or an image of a single question. The API returns the question's content, answer, solution, and the URLs of any available video explanations.
API overview
API name: searchQuestion
Description: Search for questions using either text or an image. For a text search, provide the question text. For an image search, provide an image of a single question. The API returns a list of matching questions, including video URLs if available. If no matches are found, the question list is an empty array.
Item | Description |
Request method | POST |
Endpoint |
|
Request format |
|
Authentication method | The |
This service uses a vertical search billing method, charged per 1,000 successful calls. Results without video cost CNY 44 per 1,000 calls, and results with video cost CNY 64 per 1,000 calls. These pricing tiers are mutually exclusive. For more details, see Vertical search billing description.
This service requires activation. Contact your business manager to enable it.
You can also request activation through our official Q&A support channel: Q&A Support
API reference
Request parameters
Parameter | Type | Required | Default | Description | Example |
type | string | Yes | None | The search method. Valid values are |
|
query | string | Required if type is TEXT. | None | The question text. It cannot be empty or contain only whitespace. This parameter is not used in IMAGE mode. | Find the refractive index of the prism and the time it takes for light to travel through it. |
imageUrl | string | Required if type is IMAGE and imageBase64 is not provided. | None | The publicly accessible HTTP or HTTPS URL of the image, which must be directly downloadable. This parameter is not used in TEXT mode. | See the image request example. |
imageBase64 | string | Required if type is IMAGE and imageUrl is not provided. | None | The Base64-encoded string of the image. Do not include a | A complete Base64-encoded image string. |
When type is IMAGE, you must provide either imageUrl or imageBase64.
Response parameters
Field | Type | Availability | Description |
requestId | string | Always | The unique request ID. Provide this ID when you contact technical support for troubleshooting. |
data | object | Always | The search result. |
data.questions |
| Always. May be an empty array. | A list of matching questions. Each object in the array represents one question. |
data.questions[].qid | string | Optional | The unique ID of the question. |
data.questions[].course | string | Optional | The academic subject. |
data.questions[].content | string | Optional | The question content. |
data.questions[].answer | string | Optional | The answer. |
data.questions[].solution | string | Optional | The solution. |
data.questions[].mixAnswer | integer | Optional | Indicates whether the content includes the answer. 1: Yes, 0: No. |
data.questions[].keyPoint |
| Optional | Information about key points. |
data.questions[].keyPoint[].content | string | Optional | The content of the key point. |
data.questions[].styleType | string | Optional | The style type, used for styling the question with CSS. |
data.questions[].video | object | Optional or null | The video information. |
data.questions[].video.videoInfo | object | Optional | The video information. |
data.questions[].video.videoInfo.videoId | string | Optional | The video ID. |
data.questions[].video.videoInfo.playUrl | string | Optional | The video playback URL. |
data.questions[].video.videoTag | integer | Optional | Indicates if the video is for the original question or a similar one. 0: Original question; 1: Similar question. |
data.questions[].video.videoInfo.coverUrl | string | Optional | The cover image URL. |
data.questions[].video.videoInfo.duration | integer | Optional | The video duration in seconds. |
data.questions[].video.videoInfo.resolutionList | array<string> | Optional | The available resolutions for the video. |
data.questions[].video.videoInfo.resolution | string | Optional | The video resolution. |
data.questions[].video.videoInfo.size | string | Optional | The file size in bytes. |
data.questions[].video.videoInfo.width | string | Optional | The width in pixels. |
data.questions[].video.videoInfo.height | string | Optional | The height in pixels. |
Examples
The image URL in the example is a placeholder. Replace it with the URL of an actual, downloadable image of a single question. The response example illustrates the data structure.
Text search request
{
"type": "TEXT",
"query": "Find the refractive index of the prism and the time it takes for light to travel through it."
}Image search request
{
"type": "IMAGE",
"imageUrl": "https://example.com/images/prism.png"
}When using Base64, replace imageUrl with imageBase64 and provide the complete encoded string. Do not include both parameters in the same request.
Response example
{
"requestId": "example-request-id",
"data": {
"questions": [
{
"qid": "fe1877abc7ef40b48ef24e70b21e9338",
"course": "Physics",
"content": "<div>The figure shows the cross-section of a cylindrical prism made of a transparent material...</div>",
"answer": "<div>Solving the equations above gives: <img class=\"img-max\" data-math=\"n%3D%5Cdfrac%7B%5Csqrt%7B6%7D%7D%7B2%7D\"></div>",
"solution": "<div>The refracted ray undergoes total internal reflection at point O, so the angle of incidence equals the critical angle C...</div>",
"mixAnswer": 0,
"styleType": "questionSearch",
"keyPoint": [
{
"content": "Law of refraction"
}
],
"video": {
"videoTag": 0,
"videoInfo": {
"videoId": "f4394739b9437665",
"coverUrl": "http://image.uc.cn/s/wemedia/s/upload/2022/bda0aacded3d5ef1fc80a8a911b54b08.jpg",
"duration": 289
}
}
}
]
}
}This example is an excerpt from a response for a physics question. For brevity, the full text and formula image URLs in the content, answer, and solution fields have been omitted. If no matches are found, data.questions is an empty array [].
API call
To authenticate, pass an enabled API key in the X-API-Key request header. The following example reads the credentials from an environment variable named API_KEY. Do not hardcode your credentials in client-side applications or public code repositories.
curl -X POST 'https://cloud-iqs.aliyuncs.com/question/search' \
--header "X-API-Key: $API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"type": "TEXT",
"query": "Find the refractive index of the prism and the time it takes for light to travel through it."
}'For an image search, replace the request body with the one shown in the image search request example. The authentication and Content-Type headers remain the same.
Error codes
Before parsing an error, check the HTTP status code. A standard JSON error response includes requestId, errorCode, and errorMessage. However, the response format can vary for other errors. For instance, a 415 response may have an empty body.
Parameter error example:
{
"requestId": "example-request-id",
"errorCode": "InvalidParameter",
"errorMessage": "Image too large"
}HTTP status code | Error code | Description | Recommended action |
400 | InvalidParameter | A required field is missing, a parameter is invalid, or the image exceeds the size limit. | Verify the |
403 | Retrieval.InvalidAPIKey | The API key is invalid. | Check the |
403 | Varies based on response | Insufficient permissions or quota. | Verify that the service is enabled, and check your call permissions and available quota. |
413 | RequestTooLarge | The entire HTTP request body exceeds the size limit. | Reduce the request body size. For image searches, consider using imageUrl instead of imageBase64. |
415 | Varies based on response | Unsupported request format. | Use |
429 | ThrottlingService, QuestionSearchFailed, etc. | The request rate or concurrency exceeds the limit. | Reduce the call frequency and implement backoff and retry logic. |
502 | QuestionSearchFailed, UpstreamUnavailable, UpstreamProtocolError, OutputLimitExceeded, etc. | Search failed, the service is unavailable, the response format is invalid, or the output exceeds the limit. | Ensure the image URL is accessible and the image content is valid. If the issue persists, contact technical support. |
503 | ServiceUnavailable | The service is temporarily unavailable. | Retry the request later. If the issue persists, contact technical support. |
504 | RequestTimeout | The request timed out. | Retry the request later. If the issue persists, contact technical support and provide the request ID. |