Integration approaches
This document describes both the frontend and backend integration approaches to retrieve and display results from Constructor on your e-commerce website. Both approaches utilize Constructor's REST API.
Frontend integration (recommended)
A frontend REST API integration uses Constructor’s JavaScript libraries to contact Constructor's REST API from the browser. A user's search query is passed to Constructor's REST API, and a response is received in JSON format. The site’s front-end framework parses the JSON and uses it to render the HTML for the search result pages.
Advantages
- Front-end REST API integrations are ideal for customers with existing search interfaces that use a front-end framework like React. Such customers can often simply replace calls to their existing search service with those to Constructor’s API.
- Faster results - Frontend integrations allow your users’ browsers to interact directly with Constructor servers, which are globally distributed and optimized to return results within milliseconds. A backend integration will add the latency created by your server-side code to this process, providing a slower user experience. Due to an additional network hop, latency will be introduced and it may take longer to deliver results to users.
- Constructor has a global infrastructure of servers that support geo-directed requests from end users for front-end API implementations.
- Requests issued directly from the users browser contain a number of useful data points, namely
User-Agent
and request IP. These are necessary for Constructor to understand the origin of requests to adequately ensure DDOS prevention and are automatically transmitted in a frontend integration.
Challenges
- Customers are responsible for developing and maintaining their own search interface.
Documentation for the frontend JavaScript client can be found on the Client libraries / SDKs guide, and documentation for the Constructor REST API can be found within the API Reference section.
Backend integration
Similar to a front-end REST API integration, a backend REST API integration uses a server side programming language like Java, JavaScript, Python, Ruby, etc. to contact Constructor's REST API. A user's search query is passed to the customer's own web servers. Those web servers then call Constructor's REST API and receive a response in JSON format. The servers parse the JSON and use it to create the HTML for the search result pages. That HTML is then returned to the end-user.
Advantages
- Backend REST API integration is great for teams that want to implement complex search experiences using server side logic.
- This approach allows customers to perform advanced processing such as adding business logic to search result page rendering and integrating with other services that need to add data to search results before displaying them.
Challenges
- As with a frontend REST API integration, customers are responsible for developing and maintaining their own search interface.
- Constructor’s machine learning algorithms depend on per-user behavioral tracking to optimize search results. This tracking is accomplished on the frontend by generating a unique, random, anonymous ID for each visitor. A backend integration requires passing this ID from the browser to the backend, and sending that with the API calls to Constructor’s servers.
- Constructor has a worldwide network of high-performance search servers. Frontend integrations leverage Constructor’s custom DNS setup to send user queries to the data center geographically closest to them. Because backend integrations are passed through the customer’s own servers, this performance benefit is not available. More information can be found on the Data center pinning guide.
- Backend integrations add further latency to search requests by requiring all searches to pass through the backend servers.
More details about a backend REST API Integration can be found in the Backend Integrations section, and full documentation for the Constructor REST API can be found in the API Reference.
Note that with either a frontend or backend REST API integration, a JavaScript beacon is still required to be placed on all sites to track user behavior such as search result clicks and conversions.
Updated about 2 months ago