Getting Started



You can either use a package manager like npm or include a <script> tag.

Node.js / React Native / Browserify / webpack

We are browserifyable and webpack friendly.

npm install algoliasearch --save

TypeScript typings

For Typescript typings, we provide the definition file via typings

npm install --save @types/algoliasearch


bower install algoliasearch -S

<script> tag using CDNS

jsDelivr is a global CDN delivery for JavaScript libraries.

To include the latest releases and all upcoming features and patches, use this:

<script src=""></script>
Other CDNS

We recommend using jsDelivr, but algoliasearch is also available at:

  • unpkg:

Search only/lite client

We have a lightweight build available that can only do searches. Use it when filesize is important to you or if you like to include only what you need.

Find it on jsDelivr:

<script src=""></script>

Init index - initIndex

To initialize the client, you need your Application ID and API Key. You can find both of them on your Algolia account.

// var algoliasearch = require('algoliasearch');
// var algoliasearch = require('algoliasearch/reactnative');
// var algoliasearch = require('algoliasearch/lite');
// or just use algoliasearch if you are using a <script> tag
// if you are using AMD module loader, algoliasearch will not be defined in window,
// but in the AMD modules of the page

var client = algoliasearch('applicationID', 'apiKey');
var index = client.initIndex('indexName');'something', function searchDone(err, content) {
  console.log(err, content);

Quick Start

In 30 seconds, this quick start tutorial will show you how to index and search objects.

Without any prior configuration, you can start indexing 500 contacts in the contacts index using the following code:

var index = client.initIndex('contacts');
var contactsJSON = require('./contacts.json');

index.addObjects(contactsJSON, function(err, content) {
  if (err) {

You can now search for contacts using firstname, lastname, company, etc. (even with typos):

// firstname'jimmie', function(err, content) {

// firstname with typo'jimie', function(err, content) {

// a company'california paint', function(err, content) {

// a firstname & company'jimmie paint', function(err, content) {

Settings can be customized to tune the search behavior. For example, you can add a custom sort by number of followers to the already great built-in relevance:

  'customRanking': ['desc(followers)']
}, function(err, content) {

You can also configure the list of attributes you want to index by order of importance (first = most important):

  'searchableAttributes': [
}, function(err, content) {

Since the engine is designed to suggest results as you type, you’ll generally search by prefix. In this case the order of attributes is very important to decide which hit is the best:'or', function(err, content) {
});'jim', function(err, content) {