> ## Documentation Index
> Fetch the complete documentation index at: https://www.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, an Algolia <Index /> destination,
and an on-demand synchronization task.

## Before you begin

If you don't have an Algolia account, [create one](https://www.algolia.com/users/sign_up) for free.

## 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 changes records before the connector indexes them.
* The task controls when the connector runs.

<Steps>
  <Step title="Choose the 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="Create the JSON source">
    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" id="transform">
    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.

    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;
    }
    ```

    Select **Save**.
  </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">
    Select **On demand** and **Full reindexing**.
  </Step>

  <Step title="Run the task">
    Select **Create task**, then **Run** and 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 build the UI,
  [configure `product_type` as an attribute for faceting](/doc/guides/managing-results/refine-results/faceting/how-to/declaring-attributes-for-faceting-with-dashboard)
  in 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 you update the source, [run the connector 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 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 file from a standard request.
* **POST** if your server requires a POST request.

### Source authentication

Select the authentication method for your file:

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

### Transformations

Use transformations to add computed attributes or change values before the connector indexes your records.
To use a transformed attribute for search, faceting, or ranking,
update the relevant [index settings](/doc/api-reference/settings-api-parameters),
such as `searchableAttributes`, `attributesForFaceting`, or `customRanking`.

<Note>
  Test transformations with repeated task runs.
  Transformations that read from and write to the same attribute,
  or extract a value and then delete the source attribute,
  can produce different results when the task runs again.
</Note>

### Synchronization schedule

After you create a task,
you can [edit it in the Algolia dashboard](https://dashboard.algolia.com/connectors/tasks) to choose when the connector runs:

* **On demand**. Run the connector manually.
* **Scheduled**. Select a predefined schedule or enter a custom [cron expression](https://crontab.guru/).

### Indexing strategy

You can choose how the connector updates your index.
For information about full reindexing, full record updates, and partial record updates,
see [Data synchronization strategies](/doc/guides/sending-and-managing-data/send-and-update-your-data/in-depth/the-different-synchronization-strategies).

## 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)
