Socket
Socket
Sign inDemoInstall

algoliasearch

Package Overview
Dependencies
15
Maintainers
10
Versions
324
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

algoliasearch

A fully-featured and blazing-fast JavaScript API client to interact with Algolia API.


Version published
Maintainers
10
Weekly downloads
1,401,049
decreased by-9.73%

Weekly downloads

Package description

What is algoliasearch?

The algoliasearch npm package is a JavaScript client for Algolia, a hosted search API that provides a fast and accurate search experience for websites and mobile applications. The package allows developers to integrate Algolia's search capabilities into their JavaScript applications, enabling features such as full-text search, faceting, filtering, and geolocation queries.

What are algoliasearch's main functionalities?

Search

Perform a search query on an Algolia index and retrieve the results.

const algoliasearch = require('algoliasearch');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const index = client.initIndex('your_index_name');
index.search('query string').then(({ hits }) => {
  console.log(hits);
});

Indexing

Add or update a record in an Algolia index.

const algoliasearch = require('algoliasearch');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const index = client.initIndex('your_index_name');
index.saveObject({ objectID: '1', name: 'Foo' }).then(() => {
  console.log('Object indexed');
});

Configure Index Settings

Configure settings of an Algolia index to define ranking, attributes for faceting, etc.

const algoliasearch = require('algoliasearch');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
const index = client.initIndex('your_index_name');
index.setSettings({
  searchableAttributes: ['name', 'description'],
  customRanking: ['desc(popularity)']
}).then(() => {
  console.log('Settings updated');
});

Manage Indices

List all indices in your Algolia application and manage them.

const algoliasearch = require('algoliasearch');
const client = algoliasearch('YourApplicationID', 'YourAdminAPIKey');
client.listIndices().then(({ items }) => {
  console.log(items);
});

Other packages similar to algoliasearch

Readme

Source

Algolia for JavaScript

The perfect starting point to integrate Algolia within your JavaScript project

NPM version NPM downloads jsDelivr Downloads License

DocumentationInstantSearchCommunity ForumStack OverflowReport a bugSupport

✨ Features

  • Thin & minimal low-level HTTP client to interact with Algolia's API
  • Works both on the browser and node.js
  • UMD compatible, you can use it with any module loader
  • Built with TypeScript

💡 Getting Started

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

npm install algoliasearch

Then, create objects on your index:

const algoliasearch = require("algoliasearch");

const client = algoliasearch("YourApplicationID", "YourAdminAPIKey");
const index = client.initIndex("your_index_name");

const objects = [
  {
    objectID: 1,
    name: "Foo"
  }
];

index
  .saveObjects(objects)
  .then(({ objectIDs }) => {
    console.log(objectIDs);
  })
  .catch(err => {
    console.log(err);
  });

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

index
  .search("Fo")
  .then(({ hits }) => {
    console.log(hits);
  })
  .catch(err => {
    console.log(err);
  });

For full documentation, visit the online documentation.

📄 License

Algolia JavaScript API Client is an open-sourced software licensed under the MIT license.

FAQs

Last updated on 27 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc