> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON connector

> Index your data from a hosted JSON file.

export const Records = () => <Tooltip tip="A record is a searchable object in an Algolia index. Each record consists of named attributes." cta="Algolia records" href="/doc/guides/sending-and-managing-data/prepare-your-data#algolia-records">
    records
  </Tooltip>;

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

Use the JSON connector to index <Records /> from a hosted JSON file, without writing an indexing script.

In this quickstart, you create a source for a public product dataset, a destination for an Algolia <Index />, and an on-demand task that syncs the source to the destination.

## Before you begin

Make sure you have [an Algolia account](https://www.algolia.com/users/sign_up).
Create one for free if you don't already have one.

## Set up the JSON connector

Create a source, destination, transformation, and synchronization task for the sample product dataset.

* The source tells the connector where to fetch the JSON file.
* The destination tells the connector which Algolia index to write to.
* The transformation enriches records.
* The task controls when the connector runs.

<Steps>
  <Step title="Create a JSON connector">
    Connect the JSON source for the hosted sample product dataset.

    1. Go to the Algolia dashboard and select your Algolia application.
    2. Go to the [**Connectors**](https://dashboard.algolia.com/connectors) page in the Algolia dashboard.
    3. Select the JSON connector and click **Connect**.
  </Step>

  <Step title="Configure the source URL">
    1. Select **None** as your authentication method under **Is your data source protected?**.
    2. In **URL**, enter `https://dashboard.algolia.com/api/1/sample_datasets?type=apparel`.
    3. Select **GET** as the **HTTP Method**.
  </Step>

  <Step title="Set the unique property identifier">
    1. In **Unique property identifier**, enter `objectID`.
    2. In **Connector name**, enter `Quickstart products JSON source`.
    3. Select **Create source**.
  </Step>

  <Step title="Transform the records">
    This transformation adds a `price_range` attribute to each record.
    After the connector indexes your records, you can display `price_range` or configure it as a facet.

    1. Select **Transform using the code editor** and replace the placeholder **Transformation code** with this function:

       ```js JavaScript icon=code expandable theme={"system"}
       async function transform(record, helper) {
         const price = Number(record.price);

         if (!Number.isFinite(price)) {
           return record;
         }

         if (price < 25) {
           record.price_range = "Under $25";
         } else if (price < 50) {
           record.price_range = "$25 to $49";
         } else if (price < 100) {
           record.price_range = "$50 to $99";
         } else {
           record.price_range = "$100 and up";
         }

         return record;
       }
       ```

    2. Preview the transformation and confirm that the output record includes `price_range`.

    3. **Save** the transformation.
  </Step>

  <Step title="Create the destination index">
    Choose the Algolia index where the connector stores the product records.

    1. Under **Connect your data to Algolia Search**, enter `quickstart-products`.

           <Warning>
             If you enter the name of an existing index, the connector overwrites the records and settings in that index.
           </Warning>

    2. Under **Index credentials**, select **Create one for me**. To use an existing key, choose one with the `addObject`, `deleteIndex`, and `editSettings` [ACLs](/doc/guides/security/api-keys#access-control-list-acl).

    3. In **Name**, enter `Quickstart products destination`.

    4. Select **Create destination**.
  </Step>

  <Step title="Create an on-demand synchronization task">
    Ensure **On demand** and **Full reindexing** are selected.
  </Step>

  <Step title="Run the task">
    1. Select **Create task** and then **Run**.
    2. Wait for the task to finish.
  </Step>

  <Step title="Verify the indexed records">
    When the task completes, open the [`quickstart-products` index in the Algolia dashboard](https://dashboard.algolia.com/explorer/browse/quickstart-products).
    The index contains product records with attributes such as `title`, `description`, `product_type`, `price`, `price_range`, and `showcase_image`.
  </Step>
</Steps>

<Info>
  You can use this index as the data source for [Build your first search experience](/doc/guides/get-started/quickstart).
  Before you start the UI steps in that quickstart, [configure](/doc/guides/managing-results/refine-results/faceting/how-to/declaring-attributes-for-faceting-with-dashboard) `product_type` as a facet for the `quickstart-products` index.
</Info>

## Index your own JSON data

To index your own records, update the connector source URL to point to a JSON file you host.
After updating the source, run the [task](https://dashboard.algolia.com/connectors/tasks) again to index your records.

### Source file format

Your JSON file must contain an array of JSON objects.
For example:

```json JSON icon=braces theme={"system"}
[
  {
    "id": "product-1",
    "title": "Product name",
    "description": "Product description",
    "product_type": "Product type",
    "price": 49.99
  }
]
```

Each object must include a property with a value that's unique across all records (`id` in this example).
In the source configuration, set **Unique property identifier** to that property so the connector can use it as the Algolia `objectID`.

### Source file location

Update the connector source URL to point to your hosted JSON file.
The source URL can use `http`, `https`, `ftp`, `ftps`, or `sftp`.
For `http` or `https` sources, choose the request method your server expects:

* **GET** if your server returns the JSON file from a standard request.
* **POST** if your server requires a POST request.

### Authentication

Select the [authentication](https://dashboard.algolia.com/connectors/authentications) method for your file:

* **None** if the file is public.
* **Basic Auth** if the file requires a username and password.

### Transformations

Use the transformation to add computed attributes before the connector indexes your records.
If you want to search, facet, or rank by a computed attribute, update the relevant [index settings](/doc/api-reference/settings-api-parameters),
such as `searchableAttributes`, `attributesForFaceting`, or `customRanking`.

### Schedule

Choose when the connector fetches your data:

* **On demand**. The connector only fetches data when you manually run it from the Algolia dashboard's [Tasks](https://dashboard.algolia.com/connectors/tasks) page.
* **Scheduled**. The connector runs on a schedule. Select a schedule from the list or enter a custom schedule with a [cron expression](https://crontab.guru/).

## Limitations

This connector is subject to the following limitations:

* [Connectors limits](/doc/guides/scaling/algolia-service-limits/#connectors-limits)
* [Transformation limits](/doc/guides/scaling/algolia-service-limits/#data-transformation-and-fetch-limits)

## See also

* [Prepare your records for indexing](/doc/guides/sending-and-managing-data/prepare-your-data)
* [Transform your data with code](/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data-with-code)
