Icon indexing white

Exporting Index Data

Last updated 01 August 2017

Before starting

Make sure you understand the following Algolia Concepts before starting this tutorial:


In this tutorial we will review how to export the data of an index to a file.

To accomplish this, we will leverage the browse feature of Algolia.

There is currently no way to export your index data directly from your Algolia Dashboard as indices can potentially be quite large (in the tens of gigabytes for example).

Initializing the client

// composer autoload
require __DIR__ . '/vendor/autoload.php';

// if you are not using composer
// require_once 'path/to/algoliasearch.php';

$client = new \AlgoliaSearch\Client('YourApplicationID', 'YourAdminAPIKey');

$index = $client->initIndex('your_index_name');
// var algoliasearch = require('algoliasearch');
// var algoliasearch = require('algoliasearch/reactnative');
// var algoliasearch = require('algoliasearch/lite');
// import algoliasearch from 'algoliasearch';
// or just use algoliasearch if you are using a <script> tag
// if you are using AMD module loader, algoliasearch will not be defined in window,
// but in the AMD modules of the page

var client = algoliasearch('YourApplicationID', 'YourAPIKey');
var index = client.initIndex('your_index_name');

Exporting the index

The browse method, detailed in the Backup / Export an index section, allows us to retrieve results beyond the 1,000 default limit. After retrieving them, we’ll need to save them to a file.

$objects = [];

foreach ($index->browse('') as $hit) {
    $objects[] = $hit;

file_put_contents('your_filename', json_encode($objects));

Note that we use an empty query as the argument of the browse to indicate that we want to browse all records.

What’s next

Continue building your Algolia knowledge with these tutorials:

© Algolia - Privacy Policy