Skip to main content
The Ruby API client follows semantic versioning.

Upgrade from version 1 to version 2

The Ruby client is fully rebuilt while keeping a similar design to make it as smooth as possible to upgrade. It’s compatible with Ruby 2.2 and later.

Upgrade the library

In your Gemfile, replace the algoliasearch gem with the algolia gem.
Command line
Then, run the following command to install all dependencies:
Command line

Class names

Most classes have a different name and namespace in the new version. The most used classes are now as follows:
  • Algolia::ClientAlgolia::Search::Client
  • Algolia::IndexAlgolia::Search::Index
  • Algolia::AccountClientAlgolia::Account::Client
  • Algolia::AnalyticsAlgolia::Analytics::Client
  • Algolia::InsightsAlgolia::Insights::Client

Client instantiation

There’s a slight change in how you instantiate the client. Index initialization remains the same:
Ruby
By default, the keys of the response hashes are symbols. If you want the keys to be strings instead of symbols, you can set the symbolize_keys configuration option to false:
Ruby

Instantiate with configuration

You can instantiate all clients using configuration objects. This helps you change their default behavior and settings, such as the default region in the Insights client or custom hosts in the Search client. All setters have been moved from the client to the configuration object. If, for instance, you rely on the set_extra_headers method or have configured timeouts by passing options to the client during initialization, you need to change your code to use a configuration object. For example:
Ruby

Optional parameters

To have the most consistent, predictable, and future-proof method signatures, methods follow two rules:
  • All required parameters have a single argument each
  • All optional arguments are part of a hash called opts as the last argument
Most method names remain the same, just the arguments have changed. Typically, optional parameters have been removed, which you must now pass in the opts hash. The same goes for any search_parameters and request_options arguments. For example:
Ruby
Besides moving all optional parameters, go through all method changes to see how they’ve changed.

New methods

The new client introduces some new methods. Most of these are helper methods: the underlying feature was already available, but required either deeper understanding or custom code.

List of method changes

Client methods

multiple_queries

The strategy parameter is no longer a string, but a key in the opts.
Ruby

generate_secured_api_key

This method moved to the Algolia::Search::Client class.
Ruby

add_api_key

acl is now a single parameter. The other parameters have been moved to the opts.
Ruby

update_api_key

This method is now a member of the Algolia::Search::Client class.
Ruby

get_secured_api_key_remaining_validity

This method moved to the Algolia::Search::Client class.
Ruby

list_user_ids

The page and hitsPerPage parameters are now part of the opts hash.
Ruby

search_user_ids

The clusterName, page, and hitsPerPage parameters are now part of the opts hash.
Ruby

get_logs

The offset, length, and type parameters are now part of the opts hash.
Ruby

Index methods

searchParameters and opts are combined in a single parameter.
Ruby

search_for_facet_values

searchParameters and opts are combined in a single parameter.
Ruby

find_object

The method takes a lambda, proc, or block as the first argument (anything that responds to call), and the opts as the second.
Ruby

get_object_position

The class name has changed, but the method remains the same.
Ruby

add_object and add_objects

These methods are removed in favor of save_object and save_objects.

partial_update_object

The createIfNotExists flag is now part of the opts parameter. It defaults to false in version 2. (It was true in version 1.) You only need to specify the objectID in the record to be updated, not as an argument when using the method. createIfNotExists is now part of the opts parameter.
Ruby

partial_update_objects

The createIfNotExists flag is now part of the opts parameter. It defaults to false in version 2. (It was true in version 1.)
Ruby

clear_index

Renamed to clear_objects.
Ruby

get_object and get_objects

The attributesToRetrieve parameter is now part of the opts.
Ruby

delete_index

Instead of calling the delete_index method on the client, you should call the delete method directly on the index object.
Ruby

browse

Renamed to browse_objects.
Ruby

save_synonym

You only need to specify the objectID in the synonym to be saved, not as an argument when using the method.
Ruby

batch_synonyms

Renamed to save_synonyms. The forwardToReplicas and replaceExistingSynonyms parameters are now part of the opts hash.
Ruby

export_synonyms

Renamed to browse_synonyms.
Ruby

save_rule

You only need to specify the objectID in the rule to be saved, not as an argument when using the method.
Ruby

batch_rules

Renamed to save_rules. The forwardToReplicas and clearExistingRules parameters should now be part of the opts.
Ruby

delete_rule

The forwardToReplicas parameter is now part of the opts.
Ruby

clear_rules

The forwardToReplicas parameter is now part of the opts.
Ruby

export_rules

Renamed to browse_rules.
Ruby
Last modified on May 7, 2026