Enrich your records with Fetch
On this page
Fetch lets you enrich your Algolia data directly within your transformation pipeline. Using a JavaScript function within your transformation step, you can retrieve information from third-party APIs to enhance the quality and relevance of your search results. Algolia Fetch is only available on certain pricing plans.
Using Fetch affects your record ingestion rate. To avoid slowing down your indexing process, ensure you use third-party APIs that are fast and reliable. Use Fetch for operations that can be completed quickly.
Create a transformation
- Go to the Algolia dashboard and select your Algolia application.
- On the left sidebar, select Data sources.
- Open the Connectors page.
- Select a connector and click Connect to start creating your task.
- Create a new source or select an existing one.
- To create a transformation function, click Create transformation.
Retrieve and store secrets
To call an external API, you typically need an API key or other credential type (such as basic access authentication or OAuth 2.0). You can store these credentials as a secret and reference them in your transformation code.
- Retrieve the secret from the third-party API.
- In your transformation, click Secret.
- Paste in the third-party API key, give it name, then click Add.
You can now add the secret to your transformation code.
1
const mySecretValue = helper.getSecret("mySecretName");
How to use Fetch Helper Functions
- Click Helper Functions.
- Select Fetch / API
- Select a helper and click Add.
You can either use third-party APIs directly or use a generic Fetch function.
Third-party APIs
Helper | Description |
---|---|
OpenAI - Text Generation | Generate text based on a prompt. You need an OpenAI API key to use this function. For more information, see the OpenAI text generation documentation. |
OpenAI - Vision | Generate a description or tags for an image. You need an OpenAI API key to use this function. For more information, see the OpenAI vision documentation. |
Convert currency | Convert a currency to another. You need a CurrencyAPI API key to use this function. For more information, see the CurrencyAPI documentation . |
Translate text | Translate text from one language to another. You need a DeepL API key to use this function. For more information, see the DeepL documentation. |
Generic Fetch function
This function lets you connect to any service with an API.
Helper type | Description |
---|---|
Fetch with API key (in header) | Connect to any service with an API key in the header. |
Fetch with API key (in URL) | Connect to any service with an API key in the query. |
Fetch with Basic Auth | Connect to any service with basic access authentication. |
There’s a timeout and response size limit on all transformations that include Fetch requests.