The perfect starting point to integrate Algolia within your JavaScript project
Documentation • InstantSearch • Community Forum • Stack Overflow • Report a bug • FAQ • Support
- Thin & minimal low-level HTTP client to interact with Algolia's API
- Works both on the browser and node.js
- UMD and ESM compatible, you can use it with any module loader
- Built with TypeScript
To get started, you first need to install algoliasearch (or any other available API client package).
All of our clients comes with type definition, and are available for both browser and node environments.
yarn add algoliasearch@beta # or npm install algoliasearch@betaOr use a specific package:
yarn add @algolia/client-search@beta # or npm install @algolia/client-search@betaWithout a package manager
Add the following JavaScript snippet to the of your website:
<scriptsrc="https://cdn.jsdelivr.net/npm/algoliasearch@beta/dist/algoliasearch.umd.min.js"></script>You can now import the Algolia API client in your project and play with it.
import{searchClient}from'@algolia/client-search';constclient=searchClient('YOUR_APP_ID','YOUR_API_KEY');// Add a new record to your Algolia indexconstresponse=awaitclient.saveObject({indexName: '<YOUR_INDEX_NAME>',body: {objectID: 'id',test: 'val'},});// use typed responseconsole.log(response);// Poll the task status to know when it has been indexedawaitclient.waitForTask({indexName: '<YOUR_INDEX_NAME>',taskID: response.taskID});// Fetch search results, with typo toleranceconstresponse=awaitclient.search({requests: [{indexName: '<YOUR_INDEX_NAME>',query: '<YOUR_QUERY>',hitsPerPage: 50,},],});// use typed responseconsole.log(response);For full documentation, visit the Algolia JavaScript API Client.
Encountering an issue? Before reaching out to support, we recommend heading to our FAQ where you will find answers for the most common issues and gotchas with the client. You can also open a GitHub issue
The Algolia JavaScript API Client is an open-sourced software licensed under the MIT license.
