Search
This document describes the Search API endpoint.
Endpoint
curl -G "https://api.myhispreadnlp.com/search "
-H "X-Search-Location: us"
-H "Accept-Language: en-US"
-H "count: 10"
-H "page: 0"
-H "safeSearch: false"
--data-urlencode "q=spring boot"
Description
The search endpoint allows users to query the search service using a required query string along with optional parameters passed in headers. Based on the provided parameters, the service returns a search result asynchronously.
Request Parameters
Headers
-
X-Search-Location (String, optional)
Specifies the location context for the search. Default:"us"
-
Accept-Language (String, optional)
Specifies the language preference for the search results. Default:"en-US"
-
count (Integer, optional)
Indicates the number of results per page. Default:10
-
page (Long, optional)
Indicates the current page number for pagination. Default:0
-
safeSearch (Boolean, optional)
Specifies whether to filter out potentially unsafe results. Default:false
Query Parameters
- q (String, required)
The search query string. This parameter is mandatory.
Example Request
GET /search?q=spring+boot HTTP/1.1
Host: api.myhispreadnlp.com
X-Search-Location: us
Accept-Language: en-US
count: 10
page: 0
safeSearch: false
Response
The endpoint returns a reactive Mono stream containing the search results. The response format (e.g., JSON format) is determined by the underlying implementation of myHispreadSearchService.search
.
Example Response Body
{
"status": "success",
"data": {
"results": [
{
"id": "1",
"title": "Spring Boot Introduction",
"snippet": "Learn how to build a Spring Boot application..."
},
{
"id": "2",
"title": "Advanced Spring Boot Techniques",
"snippet": "This guide provides in-depth coverage of Spring Boot..."
}
// ... other search results
],
"pagination": {
"page": 0,
"count": 10,
"totalResults": 100
}
}
}
Usage Notes
-
Headers vs. Query Parameters:
While most parameters are passed as headers, remember that the query string is required and must be provided using theq
parameter. -
Default Values:
If any optional headers are omitted, their default values will be used. This ensures that the search functionality maintains consistent behavior even when some values are not provided by the client. -
Reactive Response:
The endpoint returns a Mono type, which is part of the reactive programming paradigm. This enables asynchronous processing of the search results.
Conclusion
This endpoint is designed to provide flexible search functionality by allowing clients to specify location, language, result count, pagination, and safe search through HTTP headers, along with a mandatory search query. The use of the reactive Mono wrapper ensures that the system is scalable and performant under high load.
For more detailed usage or error handling, please consult the additional API error codes and response schema documentation.
Updated 3 months ago