Skip to main content

Search API

Search API is a powerful web search service that supports multiple search parameters and filtering options, capable of returning various types of results including web pages, images, and videos. This API is compatible with most return formats.

Basic Information

  • Endpoint: /api/web-search
  • Request Method: POST
  • Data Format: JSON
  • Character Encoding: UTF-8

Request Parameters

Required Parameters

ParameterTypeRequiredDescription
querystringYesSearch keyword, cannot be empty

Optional Parameters

ParameterTypeRequiredDescription
countintNoNumber of results per page, default 10, maximum 50
offsetintNoResult offset for pagination, default 0
freshnessstringNoSearch web pages within specified time range, options:
- noLimit: No limit (default)
- oneDay: Within one day
- oneWeek: Within one week
- oneMonth: Within one month
- oneYear: Within one year
- YYYY-MM-DD..YYYY-MM-DD: Custom date range, e.g.: "2025-01-01..2025-04-06"
- YYYY-MM-DD: Specific date, e.g.: "2025-04-06"

Response Parameters

Response Example

{
"_type": "SearchResponse",
"queryContext": {
"originalQuery": "search keyword"
},
"webPages": {
"webSearchUrl": "search URL",
"totalEstimatedMatches": 1000,
"value": [
{
"id": "result ID",
"name": "webpage title",
"url": "webpage URL",
"displayUrl": "display URL",
"snippet": "content snippet",
"summary": "detailed summary",
"siteName": "website name",
"siteIcon": "website icon",
"datePublished": "publish time",
"dateLastCrawled": "crawl time",
"cachedPageUrl": "cached page URL",
"language": "webpage language",
"isFamilyFriendly": true,
"isNavigational": false,
"deepLinks": [
{
"name": "deep link name",
"url": "deep link URL",
"snippet": "deep link snippet"
}
]
}
]
}
}

Response Field Descriptions

SearchResponse

FieldTypeDescription
_typestringResponse type, fixed as "SearchResponse"
queryContextobjectQuery context information
webPagesobjectWeb search results
imagesobjectImage search results
videosobjectVideo search results

WebSearchQueryContext

FieldTypeDescription
originalQuerystringOriginal search keyword

WebSearchWebPages

FieldTypeDescription
webSearchUrlstringSearch URL
totalEstimatedMatchesintTotal number of matched web pages
valuearraySearch result list
someResultsRemovedbooleanWhether results were filtered for safety

WebPageValue

FieldTypeDescription
idstringWebpage sort ID
namestringWebpage title
urlstringWebpage URL
displayUrlstringWebpage display URL (url decoded format)
snippetstringBrief description of webpage content
summarystringText summary of webpage content
siteNamestringWebsite name
siteIconstringWebsite icon
datePublishedstringWebpage publish time (UTC+8)
dateLastCrawledstringWebpage crawl time (UTC+8)
cachedPageUrlstringCached page URL
languagestringWebpage language
isFamilyFriendlybooleanWhether the page is family-friendly
isNavigationalbooleanWhether the page is navigational
deepLinksarrayDeep link list

WebSearchImages

FieldTypeDescription
idstringImage result ID
readLinkstringImage search link
webSearchUrlstringImage search URL
isFamilyFriendlybooleanWhether the content is family-friendly
valuearrayImage result list

ImageValue

FieldTypeDescription
webSearchUrlstringImage search URL
namestringImage name
thumbnailUrlstringThumbnail URL
datePublishedstringPublish time
contentUrlstringImage content URL
hostPageUrlstringHost page URL
contentSizestringContent size
encodingFormatstringEncoding format
hostPageDisplayUrlstringHost page display URL
widthintImage width
heightintImage height
thumbnailobjectThumbnail information

WebSearchVideos

FieldTypeDescription
idstringVideo result ID
readLinkstringVideo search link
webSearchUrlstringVideo search URL
isFamilyFriendlybooleanWhether the content is family-friendly
scenariostringVideo scenario
valuearrayVideo result list

VideoValue

FieldTypeDescription
webSearchUrlstringVideo search URL
namestringVideo name
descriptionstringVideo description
thumbnailUrlstringThumbnail URL
publisherarrayPublisher information
creatorobjectCreator information
contentUrlstringVideo content URL
hostPageUrlstringHost page URL
encodingFormatstringEncoding format
hostPageDisplayUrlstringHost page display URL
widthintVideo width
heightintVideo height
durationstringVideo duration
motionThumbnailUrlstringMotion thumbnail URL
embedHtmlstringEmbed HTML
allowHttpsEmbedbooleanWhether HTTPS embed is allowed
viewCountintView count
thumbnailobjectThumbnail information
allowMobileEmbedbooleanWhether mobile embed is allowed
isSuperfreshbooleanWhether the content is super fresh
datePublishedstringPublish time

Error Codes

Error CodeDescription
400Invalid request parameters
401Unauthorized
403Forbidden
404Resource not found
429Too many requests
500Internal server error

Notes

  1. Timestamp Notes:

    • datePublished: Actual webpage publish time
    • dateLastCrawled: Webpage crawl time
    • All timestamps are in UTC+8
  2. Pagination Notes:

    • Maximum 50 results per page
    • Use offset parameter for pagination
    • Recommended to request no more than 1000 results at once
  3. Security Restrictions:

    • Some results may be filtered for security reasons
    • Check someResultsRemoved field to confirm if results were filtered
  4. Performance Recommendations:

    • Use freshness parameter to limit time range appropriately
    • Use include/exclude parameters to narrow search scope
    • Avoid frequent requests with the same keywords
  5. Compatibility Notes:

    • Some fields may vary slightly between different API versions, but core functionality remains consistent
    • Please refer to specific API version documentation for detailed field descriptions

Usage Examples

Request Example

curl -X GET "https://platform.kuaisou.com/api/web-search?query=artificial+intelligence&count=10&offset=0"

Response Example

{
"_type": "SearchResponse",
"queryContext": {
"originalQuery": "artificial intelligence"
},
"webPages": {
"webSearchUrl": "https://platform.kuaisou.com/api/web-search?query=artificial+intelligence",
"totalEstimatedMatches": 1000,
"value": [
{
"id": "https://platform.kuaisou.com/api/v1/#WebPages.0",
"name": "Artificial Intelligence - Wikipedia",
"url": "https://en.wikipedia.org/wiki/Artificial_intelligence",
"displayUrl": "en.wikipedia.org/wiki/Artificial_intelligence",
"snippet": "Artificial intelligence (AI) is intelligence demonstrated by machines, as opposed to natural intelligence displayed by animals including humans.",
"summary": "Artificial intelligence is a branch of computer science that aims to understand the nature of intelligence and produce machines that can simulate human-like intelligence."
}
]
}
}

Search API Python Demo

This document provides a simple example of how to call the Search API using Python.

Basic Call Example

import requests
import json

def search_web(query, api_key, count=10, summary=False):
"""
Execute web search

Parameters:
query (str): Search keyword
api_key (str): API key
count (int): Number of results to return, default 10
offset (int): Search page number
"""
url = "https://platform.kuaisou.com/api/web-search"

# Build request data
payload = json.dumps({
"query": query,
"offset": 1,
"count": count
})

# Set request headers
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}

# Send request
response = requests.post(url, headers=headers, data=payload)

# Check response status
if response.status_code == 200:
return response.json()
else:
raise Exception(f"Search request failed: {response.status_code} - {response.text}")

# Usage example
if __name__ == "__main__":
# Set API key
API_KEY = "sk-********" # Replace with your API key

try:
# Execute search
results = search_web(
query="What is the meaning of life?",
api_key=API_KEY,
count=10,
summary=True
)

# Print results
print(json.dumps(results, indent=2, ensure_ascii=False))

except Exception as e:
print(f"Error occurred: {str(e)}")

More Parameter Examples

# Search with time range
results = search_web(
query="Artificial Intelligence",
api_key=API_KEY,
count=20,
offset=1,
freshness="oneWeek" # Results from the past week
)

# Search within specific websites
results = search_web(
query="Python Tutorial",
api_key=API_KEY,
count=15,
offset=1
)

# Search with custom date range
results = search_web(
query="News",
api_key=API_KEY,
count=10,
summary=True,
freshness="2024-01-01..2024-03-20" # Custom date range
)