This is documentation for v3 of the PHP API clients, which is not the latest version. To see the documentation for the latest version, see PHP v4.

This is documentation for v2 of the Ruby API clients, which is not the latest version. To see the documentation for the latest version, see Ruby v3.

This is documentation for v4 of the JavaScript API clients, which is not the latest version. To see the documentation for the latest version, see JavaScript v5.

This is documentation for v3 of the Python API clients, which is not the latest version. To see the documentation for the latest version, see Python v4.

This is documentation for v8 of the Swift API clients, which is not the latest version. To see the documentation for the latest version, see Swift v9.

This is documentation for v2 of the Kotlin API clients, which is not the latest version. To see the documentation for the latest version, see Kotlin v3.

This is documentation for v6 of the C# API clients, which is not the latest version. To see the documentation for the latest version, see C# v7.

This is documentation for v3 of the Java API clients, which is not the latest version. To see the documentation for the latest version, see Java v4.

This is documentation for v3 of the Go API clients, which is not the latest version. To see the documentation for the latest version, see Go v4.

This is documentation for v1 of the Scala API clients, which is not the latest version. To see the documentation for the latest version, see Scala v2.

Required API Key: any key with the browse ACL

Method signature
$index->browseObjects()

$index->browseObjects([
  // All the following parameters are optional
  'query' => string,
  // + any browseParameters
  // + any requestOptions
])

You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.

You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

About this method

Get all records from an index.

You can 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 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 instead.

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.

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 parameter to declare which attributes you want to retrieve.

Pagination

The API clients return all results without pagination, often via iterators or similar constructs. If you need paginated results from the API, use the /browse HTTP API endpoint.

Examples

Read the Algolia CLI documentation for more information.

Get all records from an index

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?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);
}

Get all records with only a few attributes

The objectID attribute is always retrieved.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?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);
}

Parameters

query
type: string
Required

Search query.

Use an empty query to fetch all objects.

browseParameters
type: key/value mapping
default: No browse parameters
Optional

Compatible search parameters. For example:

When using browse, the engine overrides these API parameters:

When using browse, the pagination parameters hitsPerPage and page are ignored.

Personalization isn’t applied to browse requests. The enablePersonalization parameter is ignored.

requestOptions
type: key/value mapping
default: No request options
Optional

A mapping of request options to send along with the query.

Response

This section shows the JSON response returned by the API. Each API client encapsulates this response inside objects specific to the programming language, so that the actual response might be different. You can view the response by using the getLogs method. Don’t rely on the order of attributes in the response, as JSON doesn’t guarantee the ordering of keys in objects.

JSON format

1
2
3
4
5
6
7
8
9
10
11
12
13
{
  "hits": [
    {
      "firstname": "Jimmie",
      "lastname": "Barninger",
      "objectID": "433"
    }
  ],
  "processingTimeMS": 7,
  "query": "",
  "params": "filters=level%3D20",
  "cursor": "ARJmaWx0ZXJzPWxldmVsJTNEMjABARoGODA4OTIzvwgAgICAgICAgICAAQ=="
}
Field Description
hits
list

Retrieved records.

cursor
string

A cursor to retrieve the next chunk of objects. If absent, the end of the index has been reached.

params
string

URL-encoded search parameters used to filter the results.

query
string

Query text used to filter the results.

processingTimeMS
integer

Time that the server took to process the request, in milliseconds. This does not include network time.

nbHits
integer

Number of objects in the index. Present only when the query is empty and the browse is not filtered.

page
integer

Index of the current page (zero-based). Present only when the query is empty and the browse is not filtered.

hitsPerPage
integer

The maximum number of hits returned per page. Present only when the query is empty and the browse is not filtered.

nbPages
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.

Did you find this page helpful?