Search API Client for Javascript

Features

  • Gives API access to all Algolia functionality, settings, advanced features, and ML/AI products including Recommend
  • Works in node and all browsers (including IE11+)
  • Supports dynamic modules (load only what you need)
  • Built with Typescript
  • All major module formats (ESM, CJS, UMD)
  • Background retry strategy to ensure uptime
  • Thin & minimal low-level HTTP client to interact with Algolia's API
  • Batching via iterators to optimize number of network calls
  • Zero downtime reindexing feature

Version

  • Works in node and all browsers (including IE11+)
  • Built with TypeScript" down from "Features" to match the Autocomplete libraries

Related Integrations

  • InstantSearch for React, Vue, Angular, vanilla
  • Autocomplete
  • Netlify, Salesforce

Key links


Get started

First, install Algolia JavaScript API Client via the npm package manager:

1npm install algoliasearch

Then, create objects on your index:

1const algoliasearch = require("algoliasearch");
2
3const client = algoliasearch("YourApplicationID", "YourAdminAPIKey");
4const index = client.initIndex("your_index_name");
56const objects = [
7  {
8    objectID: 1,
9    name: "Foo"
10  }
11];
1213index
14  .saveObjects(objects)
15  .then(({ objectIDs }) => {
16    console.log(objectIDs);
17  })
18  .catch(err => {
19    console.log(err);
20  });

Finally, let's actually search using the search method:

1index
2  .search("Fo")
3  .then(({ hits }) => {
4    console.log(hits);
5  })
6  .catch(err => {
7    console.log(err);
8  });

Built with JavaScript on Algolia