Search API
Reference for the Glood Hydrogen Search v1 surface. For a guided walkthrough, see Search & Discovery.All search calls are v1 on the search host (
https://search.glood.ai) and authenticate with
Authorization: Bearer <apiKey> + x-shop. Params are camelCase (mapped to snake_case on the
wire); responses are snake_case exactly as returned by the backend.Hooks
React hooks, each usable within a<GloodProvider> whose client has the search app
registered (.use(search())).
useSearch()
Runs a full product search for the current params and exposes attribution helpers.params is a SearchParams (all optional; query may be ""). options.skip (default false) holds fetching until required params are ready.
Returns — UseSearchResult
useInstantSearch()
Type-ahead search. On an empty / too-short query the response carriestrending.
params is an InstantSearchParams (query required, may be ""). Use options.skip to gate on the minimum query length.
Returns — UseInstantSearchResult
useSearchConfig()
Fetches the headless search config (feature flags, filter definitions, shop, analytics, translations, storefront token).UseSearchConfigResult: { config: SearchConfigResponse | null, loading, error, refetch }.
useSearchInit() / useSearchInitReady()
GloodProvider runs the search session bootstrap once on mount (when search() is
registered), mirroring recs init. You don’t call it yourself — these hooks read its result:
useSearchInit()returns theSearchInitResponse(visitor identity, history, leanconfig,token,visit_id), ornulluntil it resolves.useSearchInitReady()returnstrueonce init has settled (success or failure).useSearchanduseInstantSearchgate their fetches on this, so they don’t fire before the session is bootstrapped.
Standalone functions
Isomorphic functions for the v1 search suite. Use them in Hydrogen route loaders (SSR) or anywhere you need the API without a React component. Every function takesoptions: FetchSearchOptions as its first argument.
Endpoints
Each function POSTs to a path under the search endpoint (defaulthttps://search.glood.ai), all
v1:
FetchSearchOptions is the shared HeadlessRequestOptions — apiKey and myShopifyDomain
are required; endpoint (default https://search.glood.ai) and debug are optional. The
version is pinned to 1 internally. In the browser, visitor_id / client_id / session_id
default from the Glood cookies when omitted.The standalone functions above POST to whatever
endpoint you pass in options. When you call
through the SearchApp (app.imageSearch(...), the track* helpers, auto-subscribed events),
routing is split automatically: imageSearch and all events go to the app’s controlEndpoint
(non-edge), while every other call uses endpoint. See
Configuration → Edge vs. non-edge routing.fetchSearchInit()
Session bootstrap — resolves the visitor, returns their history (browsed / cart / purchased product ids), a lean feature-flag config (no filter definitions, no filter tree), the storefront token and a freshvisit_id. GloodProvider runs this automatically on
mount; call it directly only for SSR or non-React use.
fetchSearchConfig()
fetchInstantSearch()
query is required (may be ""); throws locally if query is undefined/null.
fetchFilters()
fetchFilterAggregations()
fetchSearchResults()
fetchImageSearch()
Exactly one ofimage / imageUrl is required (throws locally otherwise).
sendSearchEvent()
The v1 analogue ofsendHeadlessEvent. In the browser, channel ('hydrogen'),
session_id, client_id and visitor_id are filled from cookies when omitted. Extra
snake_case fields (cart, customer, customer_privacy, …) pass through. For SSR /
non-React use; inside React prefer the SearchApp track helpers wired up by GloodProvider.
Errors — GloodApiError
Thrown by every standalone function on a non-2xx response (re-exported from the search module):SearchApp
The app instance registered viaclient.use(search()). Retrieve it from the client for
advanced / SSR usage:
Methods
Event helpers
Each emits aglood:search:* custom event via the pixel pipeline and returns void:
Track events respect the app’s pixel config: if
pixel.enabled is false, they are not sent.search() module
Factory that creates and configures the search app. Pass{ events } to narrow the standard
Shopify events forwarded to the search backend (default: all events).
SearchTrack object
Attribution payload forglood:search:* events (snake_case wire shape):
Response shapes
The key response types (SearchResponse, InstantSearchResponse, SearchConfigResponse,
FiltersResponse, FilterAggregationsResponse, ImageSearchResponse) and the shared
SearchProduct object are documented in full in
TypeScript Types → Search API Types.
Example — SearchResponse
See Also
- Search & Discovery Guide — walkthrough with rendering patterns
- Search Example — complete working route
- TypeScript Types — all search type definitions
- Event System — how search events are transmitted