Search products by keyword
POST
/api/products/text-search
const url = 'https://example.com/api/products/text-search';const options = { method: 'POST', headers: { cookie: 'better-auth.session_token=<better-auth.session_token>', 'Content-Type': 'application/json' }, body: '{"query":"example","limit":1,"offset":1,"searchFields":["sku"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/products/text-search \ --header 'Content-Type: application/json' \ --cookie better-auth.session_token=<better-auth.session_token> \ --data '{ "query": "example", "limit": 1, "offset": 1, "searchFields": [ "sku" ] }'Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”Keyword search query, pagination, and optional searchable fields.
Media type application/json
Keyword product search request.
object
query
required
string
limit
integer
offset
integer
searchFields
Array<string>
Responses
Section titled “ Responses ”Matching products and total result count.
Media type application/json
object
products
required
Array<object>
Database product matched by keyword search.
object
id
required
string
sku
required
string
name
required
string
description
required
string
totalCount
required
integer
Example generated
{ "products": [ { "id": "example", "sku": "example", "name": "example", "description": "example" } ], "totalCount": 1}The request body did not include a valid query.
Media type application/json
Standard API error payload.
object
error
required
object
code
required
string
message
required
string
issues
Array<string>
Example generated
{ "error": { "code": "example", "message": "example", "issues": [ "example" ] }}No valid Better Auth session was present.
Media type application/json
Returned when no valid Better Auth session is present.
object
error
required
string
Example generated
{ "error": "example"}The server could not complete the text search.
Media type application/json
Standard API error payload.
object
error
required
object
code
required
string
message
required
string
issues
Array<string>
Example generated
{ "error": { "code": "example", "message": "example", "issues": [ "example" ] }}