Algolia

Learn how to use Algolia with Composio

Overview

SLUG: ALGOLIA

Description

Algolia is a hosted search API that provides developers with tools to build fast and relevant search experiences for their applications.

Authentication Details

client_id
stringRequired
client_secret
stringRequired
oauth_redirect_uri
stringDefaults to https://backend.composio.dev/api/v1/auth-apps/add
scopes
string
bearer_token
string
generic_api_key
stringRequired
generic_id
stringRequired

Connecting to Algolia

Create an auth config

Use the dashboard to create an auth config for the Algolia toolkit. This allows you to connect multiple Algolia accounts to Composio for agents to use.

1

Select App

Navigate to the Algolia toolkit page and click “Setup Integration”.

2

Configure Auth Config Settings

Select among the supported auth schemes of and configure them here.

3

Create and Get auth config ID

Click “Create Integration”. After creation, copy the displayed ID starting with ac_. This is your auth config ID. This is not a sensitive ID — you can save it in environment variables or a database. This ID will be used to create connections to the toolkit for a given user.

Connect Your Account

Using OAuth2

1from composio import Composio
2from composio.types import auth_scheme
3
4# Replace these with your actual values
5algolia_auth_config_id = "ac_YOUR_ALGOLIA_CONFIG_ID" # Auth config ID created above
6user_id = "0000-0000-0000" # UUID from database/application
7
8composio = Composio()
9
10
11def authenticate_toolkit(user_id: str, auth_config_id: str):
12 connection_request = composio.connected_accounts.initiate(
13 user_id=user_id,
14 auth_config_id=auth_config_id,
15 )
16
17 print(
18 f"Visit this URL to authenticate Algolia: {connection_request.redirect_url}"
19 )
20
21 # This will wait for the auth flow to be completed
22 connection_request.wait_for_connection(timeout=15)
23 return connection_request.id
24
25
26connection_id = authenticate_toolkit(user_id, algolia_auth_config_id)
27
28# You can also verify the connection status using:
29connected_account = composio.connected_accounts.get(connection_id)
30print(f"Connected account: {connected_account}")

Using API Key

1from composio import Composio
2from composio.types import auth_scheme
3
4# Replace these with your actual values
5algolia_auth_config_id = "ac_YOUR_ALGOLIA_CONFIG_ID" # Auth config ID created above
6user_id = "0000-0000-0000" # UUID from database/app
7
8composio = Composio()
9
10def authenticate_toolkit(user_id: str, auth_config_id: str):
11 # Replace this with a method to retrieve an API key from the user.
12 # Or supply your own.
13 user_api_key = input("[!] Enter API key")
14
15 connection_request = composio.connected_accounts.initiate(
16 user_id=user_id,
17 auth_config_id=auth_config_id,
18 config={"auth_scheme": "API_KEY", "val": user_api_key}
19 )
20
21 # API Key authentication is immediate - no redirect needed
22 print(f"Successfully connected Algolia for user {user_id}")
23 print(f"Connection status: {connection_request.status}")
24
25 return connection_request.id
26
27
28connection_id = authenticate_toolkit(user_id, algolia_auth_config_id)
29
30# You can verify the connection using:
31connected_account = composio.connected_accounts.get(connection_id)
32print(f"Connected account: {connected_account}")

Tools

Executing tools

To prototype you can execute some tools to see the responses and working on the Algolia toolkit’s playground

Python
1from composio import Composio
2from openai import OpenAI
3import json
4
5openai = OpenAI()
6composio = Composio()
7
8# User ID must be a valid UUID format
9user_id = "0000-0000-0000" # Replace with actual user UUID from your database
10
11tools = composio.tools.get(user_id=user_id, toolkits=["ALGOLIA"])
12
13print("[!] Tools:")
14print(json.dumps(tools))
15
16def invoke_llm(task = "What can you do?"):
17 completion = openai.chat.completions.create(
18 model="gpt-4o",
19 messages=[
20 {
21 "role": "user",
22 "content": task, # Your task here!
23 },
24 ],
25 tools=tools,
26 )
27
28 # Handle Result from tool call
29 result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
30 print(f"[!] Completion: {completion}")
31 print(f"[!] Tool call result: {result}")
32
33invoke_llm()

Tool List

Tool Name: Add AB Test

Description

Tool to create an ab test comparing search performance between two variants. use to test different index configurations or search parameters and measure impact on click-through and conversion rates.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Browse Algolia Index

Description

Tool to retrieve all records from an index. use when you need to export or iterate through an entire index dataset.

Action Parameters

browse_parameters
object
cursor
string
index_name
stringRequired
query
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Clear Objects

Description

Tool to clear records of an index without affecting settings. use when you need to completely wipe all objects (e.g., after a bulk reindex) while preserving index configuration.

Action Parameters

index_name
stringRequired
request_options
object

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Clear Rules

Description

Tool to delete all rules in an index. use when you need to wipe all rules before re-creating them. use after confirming no critical rules require retention.

Action Parameters

forwardToReplicas
boolean
index_name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Clicked Object IDs

Description

Tool to send a click event to algolia to capture clicked items. use immediately after a user click outside of search contexts to report click events.

Action Parameters

authenticatedUserToken
string
eventName
stringRequired
indexName
stringRequired
objectIDs
arrayRequired
userToken
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Converted Object IDs

Description

Tool to send a conversion event for items outside of search context. use when tracking conversions on category pages or external flows unrelated to algolia search.

Action Parameters

authenticatedUserToken
string
eventName
stringRequired
index
stringRequired
objectIDs
arrayRequired
timestamp
integer
userToken
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Copy Index

Description

Tool to copy the specified index to a new index. use when you need to duplicate an existing index including records, settings, synonyms, and rules after confirming source and destination names.

Action Parameters

destination
stringRequired
index_name
stringRequired
scope
array

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Copy Rules

Description

Tool to copy rules from one index to another. use when you need to duplicate all query rules from a source index to a target index after confirming both names.

Action Parameters

destIndex
stringRequired
index_name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Copy Index Settings

Description

Tool to copy the settings from one index to another. use when you need to replicate index configurations without records or other data.

Action Parameters

destination
stringRequired
index_name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Index

Description

Tool to delete the specified index and all its records. use when you need to permanently remove an index after confirming it's no longer needed.

Action Parameters

index_name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Multiple Records

Description

Tool to delete multiple records from an algolia index. use when you need to remove multiple objects by their ids.

Action Parameters

index_name
stringRequired
object_ids
arrayRequired
request_options
object

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Rule

Description

Tool to delete the specified rule from an index. use when you need to permanently remove a rule after confirming its objectid.

Action Parameters

forward_to_replicas
boolean
index_name
stringRequired
object_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Delete Synonym

Description

Tool to delete a synonym from a specified index. use when you need to remove an existing synonym by its objectid.

Action Parameters

forward_to_replicas
boolean
index_name
stringRequired
object_id
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Export Rules

Description

Tool to export all rules defined on an index. use when you need to backup or migrate index rules.

Action Parameters

cursor
string
index_name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Find Object

Description

Tool to find the first object matching a query or filter in an index. use when debugging relevance or filter logic after confirming index exists.

Action Parameters

attributesToRetrieve
array
filters
object
index_name
stringRequired
paginate
boolean
query
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get multiple objects

Description

Tool to retrieve multiple records from an index. use when you need to batch-fetch several objectids in one call.

Action Parameters

requests
arrayRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Object Position

Description

Tool to retrieve an object’s position in a result set. use when debugging relevance after performing a search query.

Action Parameters

object_id
stringRequired
results
objectRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Get Index Settings

Description

Tool to retrieve the settings of a specified index. use when you need to inspect index configurations after creation or update.

Action Parameters

indexName
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Index Exists

Description

Tool to check if an algolia index exists. use before performing index operations to prevent accidental index creation. example: indexexists(index name='products').

Action Parameters

index_name
stringRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Init Insights API Client

Description

Tool to initialize the algolia insights api client. use before sending any insights events.

Action Parameters

region
stringDefaults to us
store_in_cookie
booleanDefaults to True

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: List Indices

Description

Tool to list all indices and their metadata. use when you need to retrieve index names, sizes, and state before performing operations that depend on index properties.

Action Parameters

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Partial Update Objects

Description

Tool to partially update multiple records in the specified index. use when you need to change only selected fields of many objects without replacing entire records. use after confirming objectids and desired updates.

Action Parameters

indexName
stringRequired
requests
arrayRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Replace All Rules

Description

Tool to push a new set of rules, erasing previous ones. use when you need zero-downtime atomic replacement of all rules in an index.

Action Parameters

forwardToReplicas
boolean
indexName
stringRequired
requestOptions
object
rules
arrayRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Save Synonym

Description

Tool to add or update a synonym in the specified index. use when you need programmatic upsert of search synonyms after index creation.

Action Parameters

forwardToReplicas
boolean
indexName
stringRequired
objectID
stringRequired
synonym
objectRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Search Algolia Index

Description

Tool to perform a search on a specified algolia index. use after confirming the index name. example: searchindex(index name='contacts', query='apple', search params={'hitsperpage':10})

Action Parameters

index_name
stringRequired
query
stringRequired
request_options
object
search_params
object

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Search Multiple Indices

Description

Tool to perform searches across multiple indices in a single call. use when you need to batch multiple index queries into one api request.

Action Parameters

requests
arrayRequired
strategy
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Search Rules

Description

Tool to search for rules in the specified index. use when you need to retrieve rules matching a query, filtering by anchoring, context, pagination, or enabled status.

Action Parameters

anchoring
string
context
string
enabled
boolean
hitsPerPage
integer
indexName
stringRequired
page
integer
query
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Search Synonyms

Description

Tool to search for synonyms in the specified index. use when you need to retrieve synonyms matching a query or filter by type.

Action Parameters

hitsPerPage
integer
index_name
stringRequired
page
integer
query
string
type
string

Action Response

data
objectRequired
error
string
successful
booleanRequired

Tool Name: Set Index Settings

Description

Tool to update an algolia index's settings. use when you need to configure index behavior before indexing records. example: set searchableattributes and customranking for products index.

Action Parameters

forward_to_replicas
boolean
index_name
stringRequired
settings
objectRequired

Action Response

data
objectRequired
error
string
successful
booleanRequired