Strapi plugin logo for Algolia

Algolia

Index Strapi articles to Algolia indexes

Strapi plugin strapi-algolia

A strapi plugin to sync your strapi content with Algolia.

npm package version npm package daily downloads github stars github issues main workflow

Getting started

1. Installation

With Yarn

yarn add strapi-plugin-strapi-algolia
With NPM
npm install --save strapi-plugin-strapi-algolia

2. Setup environment variables

ALGOLIA_ADMIN_KEY=your_algolia_app_id
ALGOLIA_APP_ID=your_algolia_api_key

3. Configure the plugin

In Javascript

Add the following code to ./config/plugins.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'use strict';

module.exports = ({ env }) => ({
  // ...
  'strapi-algolia': {
    enabled: true,
    config: {
      apiKey: env('ALGOLIA_ADMIN_KEY'),
      applicationId: env('ALGOLIA_APP_ID'),
      contentTypes: [
        { name: 'api::article.article' },
        // ...
      ],
    },
  },
});

In Typescript

Add the following code to ./config/plugins.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
export default ({ env }) => ({
  // ...
  'strapi-algolia': {
    enabled: true,
    config: {
      apiKey: env('ALGOLIA_ADMIN_KEY'),
      applicationId: env('ALGOLIA_APP_ID'),
      contentTypes: [
        { name: 'api::article.article' },
        // ...
      ],
    },
  },
});

All configurations options

PropertyDescriptionTypeDefault value
applicationIdAlgolia application IDstring (required)
apiKeyAlgolia API Keystring (required)
indexPrefixPrefix for the Algolia indexstring`${strapi.config.environment}_`
contentTypesArray of content types needed to be indexedArray\<object> (required)
contentTypes.nameName of the content typestring (required)
contentTypes.indexAlgolia index for the current content typestring
contentTypes.idPrefixPrefix for the item idstring
contentTypes.populateWhich fields needed to be indexed on Algolia, by default all the properties are indexedobject'*' = All fields
contentTypes.hideFieldsWhich fields needed to be hidden on Algolia, by default all the properties are indexedArray\<string>[]
contentTypes.transformToBooleanFieldsWhich fields needed to be transform from null to boolean on AlgoliaArray\<string>[]

UI

For each content type configured in the plugin, a new button will be added to the content type list. This button will allow you to index all the content of the content type.

Capture d’écran 2024-04-04 à 15 14 50

Endpoints

Index all the content of a content-type

Call the following endpoint /strapi-algolia/index-all-articles with POST method.

The body must be like this:

1
2
3
{
  "name": "api::article.article"
}

You must be admin and add an authorization bearer token in the header.

1
Authorization: Bearer YOUR_TOKEN
Example with curl:
curl --request POST \
  --url https://YOUR_STRAPI_INSTANCE/strapi-algolia/index-all-articles \
  --header 'Authorization: Bearer YOUR_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
	"name": "api::article.article"
}'

Install now

npm install strapi-plugin-strapi-algolia

STATS

4 GitHub stars301 weekly downloads

Last updated

4 days ago

Strapi Version

4.24.0 and above

Author

github profile image for Wizbii
Wizbii

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.