This page documents an earlier version of the API client. For the latest version, see Upgrade.
Upgrade from version 4.x to the latest version 4
Recommendation renamed to Personalization (4.10.2)
To avoid confusion with the Algolia Recommend product, the existing “recommendation” client and methods have been renamed to personalization.@algolia/client-recommendation→@algolia/client-personalizationinitRecommendation()→initPersonalization()initRecommendation().getPersonalizationStrategy→initPersonalization().getPersonalizationStrategyinitRecommendation().setPersonalizationStrategy→initPersonalization().setPersonalizationStrategy
Upgrade from version 3 to version 4
This document lists every known breaking change. Not all these changes may affect your application, since some of these breaking changes happen in obscure parts of the client.The amount of changes in this new version is significant.
You should thoroughly test your application once the migration is over.
algoliasearch to ^4.0.0.
@types/algoliasearch package.
Import algoliasearch using ES modules
Potential impact: very high
Importing the algoliasearch function with the wildcard (*) is no longer possible.
You must import algoliasearch from the default export.
JavaScript
Internet Explorer
Potential impact: very high If you’re usingalgoliasearch in the browser,
keep in mind that the version 4 doesn’t support Internet Explorer below version 11.
You also need to use polyfills for older browsers that don’t support Promise, Object.entries, and Object.assign.
Asynchronous methods and callbacks
Potential impact: very high In the v3, all asynchronous methods took a callback function. In the v4, you can no longer pass a callback. All asynchronous methods are now exclusively Promise-based:JavaScript
The preceding example applies to all asynchronous methods that used to take a callback.
Compatibility with the Algolia search helper and InstantSearch
Potential impact: very high If you’re using any of the projects in the list below, you may need to update them to the specified versions. All tests on version 4 apply to these versions. Other versions may not work.algoliasearch-helper-js:>= 2.28.1algoliasearch-helper-js:>= 3.1.0instantsearch.js:>= 4.2.0react-instantsearch:>= 6.3.0vue-instantsearch:>= 2.7.0
Promise, Object.entries, and Object.assign.
Angular InstantSearch isn’t compatible with algoliasearch version 4.
If you’re using Angular InstantSearch, keep using algoliasearch version 3.
AngularJS, jQuery, and React Native builds
Potential impact: medium The following builds are no longer available:dist/algoliasearch.angular.jsdist/algoliasearch.jquery.jsalgoliasearch.reactnative.js
dist/algoliasearch.umd.js build directly.
The search client
The following sections present the migration guide for the search client itself. The client is the object that thealgoliasearch function returns.
JavaScript
The timeout parameter
Potential impact: low
The timeout parameter is no longer available, here is the alternative:
JavaScript
The protocol parameter
Potential impact: very low
The parameter is no longer available, here is the alternative:
JavaScript
The hosts parameter
Potential impact: very low
The parameter has changed, here is the alternative:
JavaScript
The _useCache parameter
Potential impact: low
The parameter is no longer available, here is the alternative:
JavaScript
The clearCache method
Potential impact: very low
The clearCache method is now asynchronous.
Make sure to adapt your code to wait on the promise resolution if you have dependencies.
JavaScript
The destroy method
Potential impact: low
The destroy method is now asynchronous.
JavaScript
The setRequestTimeout, setTimeouts, and getTimeouts methods
Potential impact: low
The setRequestTimeout, setTimeouts, and getTimeouts methods are no longer available.
Here is the alternative:
JavaScript
The setExtraHeader, getExtraHeader, and unsetExtraHeader methods
Potential impact: medium
The setExtraHeader, getExtraHeader, and unsetExtraHeader methods are no longer available.
JavaScript
The setUserToken method
Potential impact: very low
The method is no longer available, here is the alternative:
JavaScript
The updateApiKey method
Potential impact: low
The updateApiKey method signature has changed.
JavaScript
The addUserKeyWithValidity method
Potential impact: low
The addUserKeyWithValidity is removed. Please use addApiKey instead.
The assignUserID method
Potential impact: low
The assignUserID method signature has changed.
JavaScript
The assignUserIDs method
Potential impact: low
The assignUserIDs method signature has changed.
JavaScript
The getUserID method
Potential impact: low
The getUserID method signature has changed.
JavaScript
The removeUserID method
Potential impact: low
The removeUserID method signature has changed.
JavaScript
The searchUserIDs method
Potential impact: low
The searchUserIDs method signature has changed.
JavaScript
The generateSecuredApiKey method
Potential impact: low
The generateSecuredApiKey method signature has changed.
JavaScript
The enableRateLimitForward and disableRateLimitForward methods
Potential impact: low
Both enableRateLimitForward and disableRateLimitForward methods are no longer available. You can now add the X-Forwarded-For and X-Forwarded-For headers this way:
JavaScript
Renamed methods
Potential impact: medium The following methods don’t contain breaking changes, but either their name has changed, or they have been moved.listIndexes→listIndicesdeleteIndex→initIndex('indexName').delete()batch→multipleBatchsendQueriesBatch→searchgetTopUserID→getTopUserIDssetPersonalizationStrategy→initRecommendation().setPersonalizationStrategygetPersonalizationStrategy→initRecommendation().getPersonalizationStrategy
The search index
The following sections present the migration guide for the search index, which is the object returned by theclient.initIndex method.
JavaScript
The search method
Potential impact: very high
The search method signature has changed.
JavaScript
The searchForFacetValues method
Potential impact: high
The searchForFacetValues method signature has changed.
JavaScript
The getObject, and getObjects methods
Potential impact: low
Both getObject and getObjects are no longer available on the lite build.
Therefore, you need to include the full build to work with those methods.
In addition, the signature has changed.
JavaScript
The addObject and addObjects methods
Both the addObject and addObjects methods no longer exist,
and are replaced with the autoGenerateObjectIDIfNotExist parameter in RequestOptions on the saveObject and saveObjects methods.
Potential impact: medium
JavaScript
The partialUpdateObject and partialUpdateObjects methods
In both partialUpdateObject and partialUpdateObjects, the createIfNotExists parameter should now
be provided in RequestOptions.
Potential impact: low
JavaScript
The browse and browseFrom methods
Potential impact: low
The browseFrom method has been removed, and the browse method is no longer available on lite
builds. If you need to use browse, you need to use the full build. In addition, the signature has changed.
JavaScript
The deleteByQuery method
Potential impact: low
The method deleteByQuery has been removed. Please consider using deleteBy instead.
The ttAdapter method
Potential impact: very low
The ttAdapter method is no longer available. If you want to use this feature, please keep using v3.
Renamed methods
Potential impact: medium The following methods don’t contain breaking changes, but either their name has changed, or they have been moved.clearIndex→clearObjectsbatchSynonyms→saveSynonymsbatchRules→saveRuleslistApiKeys→client.listApiKeysaddApiKey→client.addApiKeyupdateApiKey→client.updateApiKeydeleteApiKey→client.deleteApiKeygetApiKey→client.getApiKey
The usage of gzip
Potential impact: low
The previous version of the CommonJS build accepted gzip content from the Algolia API.
This feature isn’t available on version 4.