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

> Get all records from an index.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Browse for records" href="/doc/libraries/sdk/methods/search/browse-objects" />

**Required ACL:** `browse`

Use the browse method to get records from an index, for example, to export your index as a backup.
To export *all* records, use an empty query.

Use `browse` instead of [`search`](/doc/libraries/sdk/v1/methods/search) when exporting records from your index,
when ranking, or analytics, isn't important.
**The Analytics API doesn't collect data when using `browse`.**

**Don't use this method for building a search UI**.
Use [`search`](/doc/libraries/sdk/v1/methods/search) instead.

<Info>
  You can't export your indices from the Algolia dashboard,
  only your index settings, synonyms and rules.
  For more information, see [Export and import your indices](/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/export-import-indices).
</Info>

### Ranking

Results are **ranked by attributes and custom ranking**.

For better performance, there is **no ranking for**:

* Distinct
* Typo tolerance
* Number of matched words
* Proximity
* Geo distance

### Reduce response size

If you don't need all attributes, you can reduce the size of the `browse` response.
Use the [`attributesToRetrieve`](/doc/api-reference/api-parameters/attributesToRetrieve) parameter to declare which attributes you want to retrieve.

### Pagination

The API clients return **all results without pagination**, often with *iterators* or similar constructs.
If you need paginated results from the API,
use the [`/browse` HTTP API endpoint](/doc/rest-api/search).

## Examples

### Get all records from an index

<CodeGroup>
  ```cs C# theme={"system"}
  // Use an API key with `browse` ACL
  var client = new SearchClient("YourApplicationID", "YourAPIKey");
  var index = client.InitIndex("indexName");

  // Get all records as a typed iterator
  IndexIterator<Record> indexIterator = index.Browse<Record>(new BrowseIndexQuery {});

  for (var record in indexIterator)
  {
    Console.WriteLine(record);
  }
  ```

  ```go Go theme={"system"}
  // Use an API key with `browse` ACL
  client := search.NewClient("YourApplicationID", "YourAPIKey")
  index := client.InitIndex("indexName")

  // Get all records as an iterator
  it, err := index.BrowseObjects()

  // Define the structure of your record
  var record struct {
    ObjectID string `json:"objectID"`
    // add more attributes
  }

  for {
    _, err := it.Next(&record)
    if (err != nil) {
      if (err == io.EOF) {
        break
      } else {
        panic(err)
      }
    }
    fmt.Println(record.ObjectID)
  }
  ```

  ```java Java theme={"system"}
  // Use an API key with `browse` ACL
  SearchClient client = DefaultSearchClient.create("YourApplicationID", "YourAPIKey");
  SearchIndex index = client.initIndex("indexName");

  // Get all records as an iterator
  for (Object record: index.browseObjects(new BrowseIndexQuery())) {
      System.out.println(record);
  }
  ```

  ```js JavaScript theme={"system"}
  const algoliasearch = require('algoliasearch');

  // Use an API key with `browse` ACL
  const client = algoliasearch('YourApplicationID', 'YourAPIKey');
  const index = client.initIndex('indexName');

  let hits = [];

  // Get all records as an iterator
  index.browseObjects({
    batch: batch => {
      hits = hits.concat(batch);
    }
  }).then(() => console.log(hits));
  ```

  ```kotlin Kotlin theme={"system"}
  // Use an API key with `browse` ACL
  val client = ClientSearch(
    ApplicationID("YourApplicationID"),
    APIKey("YourAPIKey")
  )
  val index = client.initIndex(IndexName("indexName"))

  // Get all records as an iterator
  index.browseObjects().forEach {
    responseSearch -> println(responseSearch)
  }
  ```

  ```php PHP theme={"system"}
  <?php
  require_once __DIR__."/vendor/autoload.php";
  use Algolia\AlgoliaSearch\SearchClient;

  // Use an API key with `browse` ACL
  $client = SearchClient::create(
    'YourApplicationID', 'YourAPIKey'
  );
  $index = $client->initIndex('indexName');

  // Get all records
  $records = $index->browseObjects();

  foreach ($records as $hit) {
    var_dump($hit);
  }
  ```

  ```python Python theme={"system"}
  from algoliasearch.search_client import SearchClient

  # Use an API key with `browse` ACL
  client = SearchClient.create("YourApplicationID", "YourAPIKey")
  index = client.init_index("indexName")

  # Get all records as iterator
  for record in index.browse_objects():
      print(record)
  ```

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

  # Use an API key with `browse` ACL
  client = Algolia::Search::Client.create(
    'YourApplicationID', 'YourAPIKey'
  )
  index = client.init_index('indexName')

  # Get all records as an iterator
  index.browse_objects.each { |record| puts record }
  ```

  ```scala Scala theme={"system"}
  // Use an API key with `browse` ACL
  val client = new AlgoliaClient(
    applicationId = "YourApplicationID",
    apiKey = "YourAPIKey"
  )
  val syncHelper = AlgoliaSyncHelper(client)
  val q = Query()

  // Get all records as an iterator
  syncHelper
    .browse("myIndex", q)
    .map(println)
  ```

  ```swift Swift theme={"system"}
  import AlgoliaSearchClient

  // Use an API key with `browse` ACL
  let client = SearchClient(
    appID: "YourApplicationID",
    apiKey: "YourAPIKey"
  )
  let index = client.index(withName: "indexName")

  // Get all records as iterator
  index.browse(query: Query("")) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Get all records with only a few attributes

The `objectID` attribute is always retrieved.

<CodeGroup>
  ```cs C# theme={"system"}
  // Use an API key with `browse` ACL
  var client = new SearchClient("YourApplicationID", "YourAPIKey");
  var index = client.InitIndex("indexName");

  // Get all records, retrieve only `title` and `content` attributes
  IndexIterator<T> indexIterator = index.Browse<T>(new BrowseIndexQuery { AttributesToRetrieve = new List<string> { "title", "content" } });

  foreach (var record in indexIterator)
  {
    Console.WriteLine(record)
  }
  ```

  ```go Go theme={"system"}
  // Use an API key with `browse` ACL
  client := search.NewClient("YourApplicationID", "YourAPIKey")
  index := client.InitIndex("indexName")

  // Get all records, retrieve only `title` and `content` attributes
  it, err := index.BrowseObjects(
      opt.Query(""),
      opt.AttributesToRetrieve(
        "title",
        "content",
      ),
  )

  // Define the structure of your record
  var record struct {
    ObjectID string `json:"objectID"`
    // add more attributes
  }

  for {
    _, err := it.Next(&record)
    if (err != nil) {
      if (err == io.EOF) {
        break
      } else {
        panic(err)
      }
    }
    fmt.Println(record.ObjectID)
  }
  ```

  ```java Java theme={"system"}
  // Use an API key with `browse` ACL
  SearchClient client = DefaultSearchClient.create("YourApplicationID", "YourAPIKey");
  SearchIndex index = client.initIndex("indexName");

  // Get all records, retrieve only `title` and `content` attributes
  BrowseIndexQuery query = new BrowseIndexQuery().setAttributesToRetrieve(
    Arrays.asList("title", "content")
  );

  for (Object record: index.browseObjects(query)) {
    System.out.println(record);
  }
  ```

  ```js JavaScript theme={"system"}
  const algoliasearch = require('algoliasearch');

  // Use an API key with `browse` ACL
  const client = algoliasearch('YourApplicationID', 'YourAPIKey');
  const index = client.initIndex('indexName');

  let hits = [];

  // Get all records, retrieve only `title` and `content` attributes
  index.browseObjects({
    query: '',
    attributesToRetrieve: [
        "title",
        "content"
      ],
    batch: batch => {
      hits = hits.concat(batch);
    }
  }).then(() => console.log(hits));
  ```

  ```kotlin Kotlin theme={"system"}
  // Use an API key with `browse` ACL
  val client = ClientSearch(
    ApplicationID("YourApplicationID"),
    APIKey("YourAPIKey")
  )
  val index = client.initIndex(IndexName("indexName"))

  // Get all records, retrieve only `title` and `content` attributes
  val query = query("") {
    attributesToRetrieve {
      +"title"
      +"content"
    }
  }
  index.browseObjects(query).forEach { 
    responseSearch -> println(responseSearch.hits)
  }
  ```

  ```php PHP theme={"system"}
  <?php
  require_once __DIR__."/vendor/autoload.php";
  use Algolia\AlgoliaSearch\SearchClient;

  // Use an API key with `browse` ACL
  $client = SearchClient::create(
    'YourApplicationID', 'YourAPIKey'
  );
  $index = $client->initIndex('indexName');

  // Get all records, retrieve only `title` and `content` attributes
  $records = $index->browseObjects(
    ['query' => '', 'attributesToRetrieve' => [ 'title', 'content' ]]
  );

  foreach ($records as $hit) {
    var_dump($hit);
  }
  ```

  ```python Python theme={"system"}
  from algoliasearch.search_client import SearchClient

  # Use an API key with `browse` ACL
  client = SearchClient.create("YourApplicationID", "YourAPIKey")
  index = client.init_index("indexName")

  # Get all records, retrieve only `title` and `content` attributes
  records = index.browse_objects(
      {"attributesToRetrieve": ["title", "content"]}
  )

  for hit in records:
      print(hit)
  ```

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

  # Use an API key with `browse` ACL
  client = Algolia::Search::Client.create(
    'YourApplicationID', 'YourAPIKey'
  )
  index = client.init_index('indexName')

  records = index.browse_objects(
    { 'attributesToRetrieve': [ 'title', 'content' ] }
  )

  records.each { |hit| puts hit }
  ```

  ```scala Scala theme={"system"}
  // Use an API key with `browse` ACL
  val client = new AlgoliaClient(
    applicationId = "YourAppplicationID",
    apiKey = "YourAPIKey"
  )
  val syncHelper = AlgoliaSyncHelper(client)
  val q = Query(
    attributesToRetrieve = Some(Seq("title", "content"))
  )
  syncHelper
    .browse("indexName", q)
    .map(println)
  ```

  ```swift Swift theme={"system"}
  import AlgoliaSearchClient

  // Use an API key with `browse` ACL
  let client = SearchClient(
    appID: "YourApplicationID",
    apiKey: "YourAPIKey"
  )
  let index = client.index(withName: "indexName")

  // Get all records, retrieve only `title` and `content` attributes
  var query = Query("") 
  query.set(\.attributesToRetrieve, to: [
        "title",
        "content"
      ])
  index.browse(query: query) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="query" type="string" required>
  Search query.

  Use an empty query to fetch all objects.
</ParamField>

<ParamField body="browseParameters" type="object">
  Compatible [search parameters](/doc/api-reference/search-api-parameters). For example:

  * Retrieve only certain attributes:
    * [`attributesToRetrieve`](/doc/api-reference/api-parameters/attributesToRetrieve)

  * Filtering:
    * [`filters`](/doc/api-reference/api-parameters/filters)
    * [`facetFilters`](/doc/api-reference/api-parameters/facetFilters)
    * [`numericFilters`](/doc/api-reference/api-parameters/numericFilters)
    * [`tagFilters`](/doc/api-reference/api-parameters/tagFilters)

  When using `browse`, the engine overrides these API parameters:

  * [`typoTolerance`](/doc/api-reference/api-parameters/typoTolerance) can only be `true` or `false`.
    If you set [`typoTolerance`](/doc/api-reference/api-parameters/typoTolerance) to `min` or `strict`,
    the engine sets it to `true` (records matching up to 2 typos are retrieved)

  * [`distinct`](/doc/api-reference/api-parameters/distinct): `false`

  * [`enableRules`](/doc/api-reference/api-parameters/enableRules): `false`

  * [`ignorePlurals`](/doc/api-reference/api-parameters/ignorePlurals): `false`

  * [`advancedSyntax`](/doc/api-reference/api-parameters/advancedSyntax): `false`

  * [`facets`](/doc/api-reference/api-parameters/facets): `[]`

  * [`getRankingInfo`](/doc/api-reference/api-parameters/getRankingInfo): `false`

  * [`attributesToHighlight`](/doc/api-reference/api-parameters/attributesToHighlight): `[]`

  * [`attributesToSnippet`](/doc/api-reference/api-parameters/attributesToSnippet): `[]`

  * [`optionalFilters`](/doc/api-reference/api-parameters/optionalFilters): `[]`

  When using `browse`, the pagination parameters [`hitsPerPage`](/doc/api-reference/api-parameters/hitsPerPage) and [`page`](/doc/api-reference/api-parameters/page) are ignored.

  Personalization isn't applied to browse requests. The [`enablePersonalization`](/doc/api-reference/api-parameters/enablePersonalization) parameter is ignored.
</ParamField>

<ParamField body="requestOptions" type="object">
  A mapping of request options to send along with the query.
</ParamField>

## Response

<ResponseField name="cursor" type="string">
  A cursor to retrieve the next chunk of objects.
  If absent, the end of the index has been reached.
</ResponseField>

<ResponseField name="hits" type="list">
  Retrieved records.
</ResponseField>

<ResponseField name="hitsPerPage" type="integer">
  The maximum number of hits returned per page.
  Present only when the query is empty and the browse is not filtered.
</ResponseField>

<ResponseField name="nbHits" type="integer">
  Number of objects in the index.
  Present only when the query is empty and the browse is not filtered.
</ResponseField>

<ResponseField name="nbPages" type="integer">
  The number of returned pages. Calculation is based on total number of hits (`nbHits`)
  divided by the number of hits per page (`hitsPerPage`), rounded to the nearest highest integer.

  Present only when the query is empty and the browse is not filtered.
</ResponseField>

<ResponseField name="page" type="integer">
  Index of the current page (zero-based).
  Present only when the query is empty and the browse is not filtered.
</ResponseField>

<ResponseField name="params" type="string">
  URL-encoded search parameters used to filter the results.
</ResponseField>

<ResponseField name="processingTimeMS" type="integer">
  Time that the server took to process the request, in milliseconds.
  This does not include network time.
</ResponseField>

<ResponseField name="query" type="string">
  Query text used to filter the results.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "hits": [
    {
      "firstname": "Jimmie",
      "lastname": "Barninger",
      "objectID": "433"
    }
  ],
  "processingTimeMS": 7,
  "query": "",
  "params": "filters=level%3D20",
  "cursor": "ARJmaWx0ZXJzPWxldmVsJTNEMjABARoGODA4OTIzvwgAgICAgICAgICAAQ=="
}
```
