1. Understand the API
Your backend sendsPOST /v1/search to the gateway address provided by Plastics. Add Authorization: Bearer <connection credential> and Content-Type: application/json. Keep the credential in server secret configuration and redact it from logs.
query is required. Page defaults to 1 and page size to 10; page is limited to 100 and page size to 20. Queries allow 1–500 characters. Brand/category filters each accept up to 10 values of up to 100 characters. Omit language/region to use the connection defaults, or send matching values. Unknown fields are rejected; visitors cannot choose another organization or publication scope.
An illustrative response is:
GET /healthz is a basic health check, not proof that credentials or search work.
Run this from your backend environment with SEARCH_GATEWAY_ORIGIN and
SEARCH_PARTNER_CREDENTIAL already set securely. The header is passed over stdin
rather than placing the secret value in command history or the process arguments.
Do not enable shell tracing or curl verbose logging.
200 with approved results verifies this authenticated API path. Also check
an expected published product and invalid/revoked credentials; a health check alone
is insufficient. Use an enabled staging connection, not an unrelated live connection.
2. Add the backend adapter
Copy the repository’sserver.mjs, contract.mjs and bounded-json.mjs into your server project. Create a handler using values from your server configuration:
rateLimiter and the route wiring above are application-specific. Supply a server-derived client identifier; do not trust a visitor-supplied identity header. The limiter must return whether the request is allowed. The runnable example shows Node request/response wiring and an in-memory limiter for local development; use a shared limiter for multiple production instances.
The adapter fixes the upstream route, rejects cross-origin requests and unsupported fields, limits response size and gives visitors generic errors. Origin checks are not visitor authentication. Add your own authentication if your website requires it. Do not turn this route into an arbitrary URL proxy, or accept a credential or gateway address from the browser.
3. Bind your search bar
Serveclient.mjs, contract.mjs and bounded-json.mjs from the same origin as your page. Adapt your existing markup, or start with:
search-setup.mjs:
onResults, retain those safety and accessibility properties and never inject result text as HTML.
The default time budgets are 15 seconds in the browser and 12 seconds in the adapter, with a shorter gateway budget. Avoid shortening the outer budget below the inner request time without providing an intentional fallback experience.
4. Run the example and verify
Use Node 22 or later. Fromintegrations/website-search, set the server-only environment variables SEARCH_GATEWAY_ORIGIN, SEARCH_PARTNER_CREDENTIAL and SEARCH_PRODUCT_ORIGIN, then run:
http://localhost:8080. This local example uses a real configured gateway and credential. The product origin must match the approved HTTPS product links. It does not install anything on your company’s website. Replace the example’s placeholder original-search route before using it on staging.
Run the repository checks with: