js_small_white Created with Sketch.

Getting Started

Install

From the backend

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

bower install algoliasearch -S

From the frontend

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

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="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
Other CDNS

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

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="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearchLite.min.js"></script>

Miscellaneous

The JavaScript client works both on the frontend (browsers) or on the backend (Node.js) with the same API.

The backend (Node.js) API can be used to index your data using your Algolia admin API keys.

Our JavaScript library is UMD compatible, you can use it with any module loader.

When not using any module loader, it will export an algoliasearch function in the window object.

Init Index

To begin, you will need to initialize the client. In order to do this you will need your Application ID and API Key. You can find both 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('YourApplicationID', 'YourAPIKey');
var index = client.initIndex('your_index_name');

The api key that is displayed here is your ADMIN API Key. To maintain security, never use your ADMIN API Key on your frontend or share it with anyone. In your frontend, use the SEARCH ONLY API Key or any other key that has search only rights.