Integration guide
Authenticate, search, and read the results.
1. Authentication
Call from your server with api-key and Content-Type: application/json headers. Keep your key private.
Open API Keys2. Request parameters
Requests support only query, count, and search_lang. query accepts a natural-language question or keywords.
| Field | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | A search question or keywords. Must not be empty. |
| count | integer | No | Desired result count. Omit or pass 0 to use the service default. |
| search_lang | string | No | Search language, for example zh-hans. The service normalizes zh to zh-hans. Click this row for the supported list. |
3. Call the search API
POST
https://api.starsg.ai/api/product/websearch/searchReplace YOUR_API_KEY and set query to your search text. count and search_lang are optional.
curl -X POST 'https://api.starsg.ai/api/product/websearch/search' \
-H 'api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"query": "北京今天的天气",
"count": 5,
"search_lang": "zh-hans"
}'Send a JSON object directly, without a body wrapper or an extra /v1.
4. Read the result
Check success first. On success, read data.references and data.data; on failure, inspect errorCode and errorMsg. The web content below is illustrative.
Success response
{
"success": true,
"data": {
"references": [
{
"website": "example.com",
"logo": "https://example.com/favicon.ico",
"title": "Example smart home news",
"url": "https://example.com/article",
"summary": "Search result summary goes here.",
"published": "",
"extra": {}
}
],
"data": [
"Search result summary goes here."
]
},
"errorCode": null,
"errorMsg": null
}data.references | Web references with titles, links and summaries. |
data.data | Result text list, nested inside the outer data object. |
references[].website / logo | Website name or domain and logo URL. |
references[].title / url / summary | Result title, original page URL and summary. |
references[].published / extra | Publication date and extra information. May be empty. |
success=true with empty references and data arrays means no valid results were found. Try different keywords or a different search language; do not treat it as an API failure.
Error response
{
"success": false,
"data": null,
"errorCode": "PARAM_INVALID",
"errorMsg": "query is required"
}Common errors and next steps
PARAM_INVALID | Check the JSON and query. Correct the parameters before retrying. |
SEARCH_FAILED | The search failed. Retry later with a limit on attempts. For persistent failures, save the call time and request identifier for support. |