Set up the Algolia JavaScript Client

Raphael Terrier
InstructorRaphael Terrier
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 5 years ago

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.

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.

egghead
egghead
~ 8 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today