Skip to main content
This page documents an earlier version of the API client. For the latest version, see Retrieve records.
Required ACL: search There are three methods you can use to get records from your indices:
  • getObject: get a single record from an index.
  • getObjects: get multiple records from an index.
  • multipleGetObjects: get multiple records from multiple indices within the same Algolia application.
Records are returned in the order in which they were requested.
When retrieving large numbers of records, be aware of the rate limitations on these processes and the impact on your analytics data.
To get all records from an index, use the browse method.

Examples

Return a list of records by their IDs

IEnumerable<Contact> contacts = index.GetObjects<Contact>(new List<string> {"myId1", "myId2"});

// Asynchronous
IEnumerable<Contact> contacts = await index.GetObjectsAsync<Contact>(new List<string> {"myId1", "myId2"});

Return a list of records with a subset of their attributes

IEnumerable<Contact> contacts = index.GetObjects<Contact>(new List<string> {"myId1", "myId2"}, attributesToRetrieve: new String[] { "firstname" });

// Asynchronous
IEnumerable<Contact> contacts = await index.GetObjectsAsync<Contact>(new List<string> {"myId1", "myId2"}, attributesToRetrieve: new String[] { "firstname" });
If an object ID isn’t found in your index, the result is null for that object ID.

Return a single record by its ID

// Retrieves all attributes
Contact res = index.GetObject<Contact>("myId");

// Asynchronous
Contact res = await index.GetObjectAsync<Contact>("myId");

// Retrieves firstname and lastname attributes
Contact res = index.GetObject<Contact>("myId", attributesToRetrieve: new List<string> { "firstname", "lastname" });

// Asynchronous
Contact res = await index.GetObjectAsync<Contact>("myId", attributesToRetrieve: new List<string> { "firstname", "lastname" });

// Retrieves only the firstname attribute
Contact res = index.GetObject<Contact>("myId", attributesToRetrieve: new List<string> { "firstname" });

// Asynchronous
Contact res = await index.GetObjectAsync<Contact>("myId", attributesToRetrieve: new List<string> { "firstname" });
If the object ID doesn’t exist in your index, this method returns an error.

Return records from multiple indices

var objectsToRetrieve = new List<MultipleGetObject>
{
  new MultipleGetObject { IndexName = "index1", ObjectID = "myId1" },
  new MultipleGetObject { IndexName = "index2", ObjectID = "myId2" }
};

IEnumerable<Object> objects = client.MultipleGetObjects<Object>(objectsToRetrieve);

// Asynchronous
IEnumerable<Object> objects = await client.MultipleGetObjectsAsync<Object>(objectsToRetrieve);

Return a list of records and send extra HTTP headers

RequestOptions requestOptions = new RequestOptions
{
    Headers = new Dictionary<string,string>{ { "X-Algolia-User-ID", "user123" } }
};

index.GetObjects(new List<string> {"myId1", "myId2"}, requestOptions);

// Asynchronous
await index.GetObjectsAsync<Contact>(new List<string> {"myId1", "myId2"}, requestOptions);

Parameters

multipleObjects
object[]
required
A list of key-value pairs that represent specific records in specific indices. (Required for multipleGetObjects).
objectID
string
required
Object ID for the record you want to get. (Required for getObject)
objectIDs
string[]
required
List of objectIDs to retrieve. (Required for getObjects).
attributesToRetrieve
string | string[]
Comma-separated list of attributes to include with each record.By default, all retrievable attributes are returned.
requestOptions
object
request options to add to the request.
You can’t use search parameters with getObjects.

Response

results
list
List of the retrieved records.

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.
JSON
{
  "results": [
    {
      "objectID": "1182729442",
      "name": "product 1"
    }
  ]
}
I