What is end-to-end AI search?
Simplicity is critical for search engines, but building one that enables that simplicity is complex. Over the last 20+ years ...
Director of Product Management
Simplicity is critical for search engines, but building one that enables that simplicity is complex. Over the last 20+ years ...
Director of Product Management
Many new AI-powered search solutions have been released this year, and each promises to provide great results, but as ...
Marketing Campaign Production Manager
When you think of “customer experience,” what comes to mind? People, right? Specifically, consumers. Retail customers. That’s easy; the ...
Sr. SEO Web Digital Marketing Manager
A potential customer is about to land on the home page of your ecommerce platform, curious to see what cool ...
Search and Discovery writer
By now, everyone’s had the opportunity to experiment with AI tools like ChatGPT or Midjourney and ponder their inner ...
Director, Product Marketing
Search has been around for a while, to the point that it is now considered a standard requirement in many ...
Senior Machine Learning Engineer
With the advent of artificial intelligence (AI) technologies enabling services such as Alexa, Google search, and self-driving cars, the ...
VP Corporate Marketing
It’s no secret that B2B (business-to-business) transactions have largely migrated online. According to Gartner, by 2025, 80 ...
Sr. SEO Web Digital Marketing Manager
Twice a year, B2B Online brings together industry leaders to discuss the trends affecting the B2B ecommerce industry. At the ...
Director of Product Marketing & Strategy
This is Part 2 of a series that dives into the transformational journey made by digital merchandising to drive positive ...
Benoit Reulier &
Reshma Iyer
Get ready for the ride: online shopping is about to be completely upended by AI. Over the past few years ...
Director, User Experience & UI Platform
Remember life before online shopping? When you had to actually leave the house for a brick-and-mortar store to ...
Search and Discovery writer
If you imagine pushing a virtual shopping cart down the aisles of an online store, or browsing items in an ...
Sr. SEO Web Digital Marketing Manager
Remember the world before the convenience of online commerce? Before the pandemic, before the proliferation of ecommerce sites, when the ...
Search and Discovery writer
Artificial intelligence (AI) is no longer just the stuff of scary futuristic movies; it’s recently burst into the headlines ...
Search and Discovery writer
Imagine you are the CTO of a company that has just undergone a massive decade long digital transformation. You’ve ...
CTO @Algolia
Did you know that the tiny search bar at the top of many ecommerce sites can offer an outsized return ...
Director, Digital Marketing
Artificial intelligence (AI) has quickly moved from hot topic to everyday life. Now, ecommerce businesses are beginning to clearly see ...
VP of Product
Apr 1st 2022 engineering
A product-based JavaScript API client should be able to run in the browser, with direct front-end DOM access, as well as in a node environment, to access back-end servers and services.
Additionally, a product-based API client should provide exhaustive and easy access to all features of the application it serves. And it should keep up-to-date with every new feature.
Finally, an API client should add extra value to the application, by adding such functionality as:
An API (application programming interface) is not just a wrapper; it’s a separate, light-weight application that enables developers to interact with a full-featured software platform.
A product-based API is an API that a company sells as a product. Google sells the Google Maps API, Stripe sells a financial API, and we sell a Search API.
A product-based API client is an API that comes in different programming languages, frameworks, and JavaScript flavors. Our clients sit on top of different REST API endpoints.
By offering an API client in a developer’s own language, they get the benefit of:
The best API design also tries to limit the amount of boilerplate code needed to instantiate, use, or parameterize an API method.
We can name a few other defining characteristics of a product-based API client:
First a word about process: We have over 10,000 customers using our API clients. With that kind of usage, we are in a good position to fine-tune our APIs based on customer support tickets, chats, and usage statistics in our logs.
However, an even greater source of truth is our own engineers. Our APIs are not just used by our customers. Our Dashboard uses our JavaScript, PHP, Ruby, and other API clients; we have inhouse use cases that implement our API clients; our client-facing tech support teams create demos, prototypes, and solutions using our API clients. With all that API testing and internal usage, we know first-hand the pain points and positive aspects of our API clients.
With all that feedback, every release includes:
For SaaS companies like ours, a JavaScript API client is critical, because of its ability to request services directly from our cloud servers without requiring customers to go though their own back-end servers. Among other things, client-side API requests improve the response time of the new API and simplify the front-end code on the front end. Because of these benefits, our JavaScript API is our most used client.
With that in mind, JavaScript APIs have to manage the challenges of client-side application development, as well as the particularities of the JavaScript language and its flavors like React, Vue, and Angular.
Here are some improvements we’ve made recently:
// For the default version const algoliasearch = require('algoliasearch'); // For the default version import algoliasearch from 'algoliasearch'; // For the search only version import algoliasearch from 'algoliasearch/lite';
We started with a simple instantiation – client application id and the API key:
const algoliasearch = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
Then we added a third parameter, allowing the developer to customize a number of additional features:
const algoliasearch = algoliasearch( 'YourApplicationID', 'YourSearchOnlyAPIKey', { timeouts: { connect: 1, read: 2, write: 30, }, requester: createBrowserXhrRequester(), logger: createConsoleLogger(LogLevelEnum.Error), responsesCache: createInMemoryCache(), requestsCache: createInMemoryCache({ serializable: false }), hostsCache: createFallbackableCache({ caches: [ createBrowserLocalStorageCache({ key: `${version}-${appId}` }), createInMemoryCache(), ], }), });
As you can see, the third parameter allows developers to define:
Make the client tree shakeable:
// Tree shakable ( 1 kb, dead code elimination ) // list the methods you use and don’t include the code of any other method const client = createSearchClient({ // .. methods: { search } });
Experts sometimes require a non-opinionated, open request to handle unexpected use cases. For example, developers can pass read/write requests to cover what is not in the API:
client.transporter.read ({ path: '', verb: 'GET' });
Note on logging: when we log these customized requests, we can take that information to create new methods in the future.
You can achieve zero-dependency simply by following JavaScript standards and using Typescript.
Instead of a single Save()
method, we added more robust methods like replaceAllObjects()
, reindex()
, copyIndex()
. This helps ensure best practices in such data-sensitive methods. Additionally, we’ve written all the code that manages retries and zero-downtime logic.
Last but not least, a product-based API client must follow the best strategies for testing and release practices. We’ll leave testing to another blog, but here’s the overall strategy we use for our release cycle:
Powered by Algolia Recommend