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

# Browse all records

> Retrieves all records from an index.

**Required ACL:** `browse`

This helper method iterates over the paginated API response from the [Browse API operation](/doc/rest-api/search/browse)
and lets you run an aggregator function on every iteration.

You can use this, for example, to retrieve all records from your index.

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  using Algolia.Search.Clients;
  using Algolia.Search.Models.Search;

  var appID = "ALGOLIA_APPLICATION_ID";
  var apiKey = "ALGOLIA_API_KEY";

  var client = new SearchClient(appID, apiKey);

  var results = await client.BrowseObjectsAsync<Hit>("ALGOLIA_INDEX_NAME", new BrowseParamsObject { Query = "test" });

  results.ToList().ForEach(record => Console.WriteLine($"  - Record: {record.ObjectID}"));
  ```

  ```go Go theme={"system"}
  package main

  import (
  	"fmt"
  	"log"

  	"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
  )

  func main() {
  	appID := "ALGOLIA_APPLICATION_ID"
  	apiKey := "ALGOLIA_API_KEY"
  	indexName := "ALGOLIA_INDEX_NAME"

  	client, err := search.NewClient(appID, apiKey)
  	if err != nil {
  		log.Fatalln(err)
  	}

  	var records []search.Hit

  	err = client.BrowseObjects(
  		indexName,
  		*search.NewBrowseParamsObject().SetQuery("test"),
  		search.WithAggregator(func(r any, err error) {
  			if err != nil {
  				log.Fatalf("There was an error: %v", err)
  			}
  			records = append(records, r.(*search.BrowseResponse).Hits...)
  		}),
  	)
  	if err != nil {
  		log.Println(err)
  	}

  	for _, record := range records {
  		fmt.Printf("- Record: %s\n", record.ObjectID)
  	}
  }
  ```

  ```java Java theme={"system"}
  package org.example;

  import com.algolia.api.SearchClient;
  import com.algolia.model.search.BrowseParamsObject;
  import com.algolia.model.search.Hit;
  import java.io.IOException;

  public class Main {

    public static void main(String[] args) throws IOException {
      var appID = "ALGOLIA_APPLICATION_ID";
      var apiKey = "ALGOLIA_API_KEY";
      var indexName = "ALGOLIA_INDEX_NAME";

      var client = new SearchClient(appID, apiKey);

      var response =
          client.browseObjects(indexName, new BrowseParamsObject().setQuery("test"), Hit.class);

      for (var record : response) {
        System.out.println("- Record: " + record.getObjectID());
      }

      client.close();
    }
  }
  ```

  ```js JavaScript theme={"system"}
  import { algoliasearch as searchClient } from "algoliasearch";

  const appId = "GRQS7LW2HJ";
  const apiKey = "3b631dd673ec758c4b280e6b230de56f";
  const indexName = "movies";

  const client = searchClient(appId, apiKey);

  let records = [];

  await client.browseObjects({
    indexName,
    aggregator: (res) => {
      records.push(...res.hits);
    },
    browseParams: {
      query: "test",
    },
  });

  records.forEach((record) => console.log(`- Record: ${record.objectID}`));
  ```

  ```kt Kotlin theme={"system"}
  package org.example

  import com.algolia.client.api.SearchClient
  import com.algolia.client.extensions.browseObjects
  import com.algolia.client.model.search.BrowseParamsObject
  import com.algolia.client.model.search.BrowseResponse
  import com.algolia.client.model.search.Hit

  suspend fun main() {
    val appID = "ALGOLIA_APPLICATION_ID"
    val apiKey = "ALGOLIA_API_KEY"
    val indexName = "ALGOLIA_INDEX_NAME"

    val client = SearchClient(appID, apiKey)

    val records = mutableListOf<Hit>()

    client.browseObjects(
        indexName = indexName,
        params = BrowseParamsObject("test"),
        aggregator = { res: BrowseResponse -> records.addAll(res.hits) })

    records.forEach { record -> println("- Record: ${record.objectID}") }
  }
  ```

  ```php PHP theme={"system"}
  <?php

  require_once realpath(__DIR__.'/vendor/autoload.php');

  use Algolia\AlgoliaSearch\Api\SearchClient;

  $appID = 'ALGOLIA_APPLICATION_ID';
  $apiKey = 'ALGOLIA_API_KEY';
  $indexName = 'ALGOLIA_INDEX_NAME';

  $client = SearchClient::create(appId: $appID, apiKey: $apiKey);

  $res = $client->browseObjects($indexName);

  $records = [];
  foreach ($res as $object) {
      $records[] = $object;
  }

  foreach ($records as $record) {
    echo '- Record ' . $record['objectID'] . "\n";
  }
  ```

  ```python Python theme={"system"}
  from algoliasearch.search.client import SearchClientSync

  app_id = "ALGOLIA_APPLICATION_ID"
  api_key = "ALGOLIA_API_KEY"
  index_name = "ALGOLIA_INDEX_NAME"

  client = SearchClientSync(app_id, api_key)

  records = []

  _ = client.browse_objects(
      index_name=index_name,
      aggregator=lambda res: records.extend(res.hits),
      browse_params={"query": "test"},
  )

  for record in records:
      print(f"- Record: {record.object_id}")
  ```

  ```ruby Ruby theme={"system"}
  require "algolia"

  app_id = "ALGOLIA_APPLICATION_ID"
  api_key = "ALGOLIA_API_KEY"
  index_name = "ALGOLIA_INDEX_NAME"

  client = Algolia::SearchClient.create(app_id, api_key)

  records = client.browse_objects(index_name, { query: "test" })

  records.each { |record| puts "- Record: #{record.algolia_object_id}" }
  ```

  ```swift Swift theme={"system"}
  import Foundation
  import Search

  let appID = "ALGOLIA_APPLICATION_ID"
  let apiKey = "ALGOLIA_API_KEY"
  let indexName = "ALGOLIA_INDEX_NAME"

  let client = try SearchClient(appID: appID, apiKey: apiKey)

  var records: [Hit] = []

  func aggregate(resp: BrowseResponse<Hit>) {
    records.append(contentsOf: resp.hits)
  }

  try await client.browseObjects(
    indexName: indexName,
    browseParams: BrowseParamsObject(query: "test"),
    aggregator: aggregate
  )

  for record in records {
    print("- Record: \(record.objectID)")
  }
  ```

  ```
  ```
</CodeGroup>

## Parameters

<Tabs>
  <Tab title="C#">
    <ParamField body="indexName" type="string" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="browseParams" type="BrowseParamsObject" required>
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="T" type="typeparam">
      The model for your records, for example, `Algolia.Search.Models.Search.Hit`.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Go">
    <ParamField body="indexName" type="string" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="browseParams" type="BrowseParamsObject" required>
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="opts..." type="IterableOptions">
      Functional options to provide extra arguments.

      <Expandable title="available functions">
        <ParamField body="search.WithAggregator" type="function">
          **Signature:** `func(aggregator func(any, error)) iterableOption`

          Provides a function that runs on every iteration,
          for example, to aggregate all records from the response.
        </ParamField>

        <ParamField body="search.WithMaxRetries" type="function">
          **Signature:** `func(maxRetries int) iterableOption`

          Sets the maximum number of iterations for this method.
          For example, with `search.WithMaxRetries(1)`
          this method stops after the first request.
          By default,
          `BrowseObjects` iterates through all pages of the API response.
        </ParamField>

        <ParamField body="search.WithTimeout" type="function">
          **Signature:** `func(timeout func(count int) time.Duration) iterableOption`

          Provides a function for calculating the waiting time between requests.
          The timeout function accepts the iteration count as parameter.
          This lets you implement varying timeouts.
        </ParamField>

        <ParamField body="search.WithHeaderParams" type="function">
          **Signature:** `func(key string, value string) requestOption`

          Sets extra header parameters for this request.
          To learn more, see [Request options](/doc/libraries/sdk/request-options).
        </ParamField>

        <ParamField body="search.WithQueryParam" type="function">
          **Signature:** `func(key string, value string) requestOption`

          Sets extra query parameters for this request.
          To learn more, see [Request options](/doc/libraries/sdk/request-options).
        </ParamField>
      </Expandable>
    </ParamField>
  </Tab>

  <Tab title="Java">
    <ParamField body="indexName" type="String" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="browseParams" type="BrowseParamsObject" required>
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="innerType" type="Class<T>" required>
      The model for your records, for example, `com.algolia.model.search.Hit`.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="JavaScript">
    <ParamField body="indexName" type="string" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="aggregator" type="function" required>
      **Signature:** `(BrowseResponse) => void`

      A function that runs on every iteration,
      for example, to aggregate all records from the response.
    </ParamField>

    <ParamField body="browseParams" type="BrowseParams">
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="validate" type="function">
      **Signature:** `(BrowseResponse) => bool`

      A function that returns true when the iteration should stop.
      By default, the iteration stops if the API response doesn't contain a `cursor` property.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Kotlin">
    <ParamField body="indexName" type="String" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="browseParams" type="BrowseParamsObject" required>
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="aggregator" type="function" required>
      **Signature:** `(BrowseResponse) -> Unit`

      A function that runs on every iteration, for example,
      to aggregate all records from the response.
    </ParamField>

    <ParamField body="validate" type="function">
      **Signature:** `(BrowseResponse) -> Boolean`

      A function that returns true when the iteration should stop.
      By default, the iteration stops if the API response doesn't contain a `cursor` field.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="PHP">
    <ParamField body="indexName" type="string" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="requestOptions" type="array">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Python">
    <ParamField body="index_name" type="str" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="aggregator" type="function" required>
      **Signature:** `(BrowseResponse) -> None`

      A function that runs on every iteration,
      for example, to aggregate all records from the response.
    </ParamField>

    <ParamField body="browse_params" type="BrowseParamsObject | None">
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="request_options" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Ruby">
    <ParamField body="index_name" type="String" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="browse_params" type="BrowseParamsObject">
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="request_options" type="Hash">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Scala">
    <ParamField body="indexName" type="String" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="browseParams" type="BrowseParamsObject" required>
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="aggregator" type="function" required>
      **Signature:** `BrowseResponse => Unit`

      A function that runs on every iteration, for example,
      to aggregate all records from the response.

      `T` is your record model's type.
    </ParamField>

    <ParamField body="validate" type="function">
      **Signature:** `BrowseResponse => Boolean`

      A function that returns true when the iteration should stop.
      By default, the iteration stops if the API response doesn't contain a `cursor` field.

      `T` is your record model's type.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>

  <Tab title="Swift">
    <ParamField body="indexName" type="String" required>
      Index name from which to retrieve the records.
    </ParamField>

    <ParamField body="browseParams" type="BrowseParamsObject" required>
      Parameters for the [Browse for records](/doc/rest-api/search/browse) request.
    </ParamField>

    <ParamField body="aggregator" type="function" required>
      **Signature:** `(BrowseResponse<T>) -> Void`

      A function that runs on every iteration, for example,
      to aggregate all records from the response.

      `T` is your record model's type.
    </ParamField>

    <ParamField body="validate" type="function">
      **Signature:** `(BrowseResponse<T>) -> Bool`

      A function that returns true when the iteration should stop.
      By default, the iteration stops if the API response doesn't contain a `cursor` field.

      `T` is your record model's type.
    </ParamField>

    <ParamField body="requestOptions" type="RequestOptions">
      Additional [request options](/doc/libraries/sdk/request-options).
    </ParamField>
  </Tab>
</Tabs>
