Set up the Algolia JavaScript Client

    Raphael TerrierRaphael Terrier

    This will get you started on how to setup the Javascript API client of Algolia search solution. To follow along the video having a free Algolia account already setup will make things easier (but is not required). Once the client is setup we will test it by pushing a couple of records to an index.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson


    Instructor: 00:00 The first step to set up the API client is to install the Algolia search package with the package manager. Then we'll create an instance of the client with the app ID and API key of the account you want to use.

    00:15 These informations are available on your Algolia dashboard. We need an API key with write access to the index you want to push data to. With that kind of variable setup, we can now initialize the index where we want to upload our data to, with the initIndex method.

    00:33 Here, we simply need to provide the name of the index we want to target. If the index doesn't exist yet, it will be automatically created. Now that our client is ready, let's use it to push some data. The fastest way to do that is directly from the script.

    00:49 We will simply create an array in our code where we will add two very basic objects, containing a string and a numeric value. Now, we can call the addObjects method, passing in the actors array. We save, and run the script.

    01:07 Let's head over to the dashboard, and we can see that both actors are there.