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.
index.GetObjects(
IEnumerable<String>objectIds,
// All the following parameters are optionalattributesToRetrieve: IEnumerable<String>,
requestOptions: RequestOptions
)
// Get a single record
index.GetObject(
StringobjectId,
// All the following parameters are optionalattributesToRetrieve: IEnumerable<String>,
requestOptions: RequestOptions
)
// Get multiple records
client.MultipleGetObjects(
multipleObjects: IEnumerable<MultipleGetObject>
)
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.
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
Copy
1
2
3
4
5
6
7
// Retrieves all attributes$index->getObject('myId');// Retrieves only firstname and lastname attributes$index->getObject('myId',['attributeToRetrieve'=>['firstname','lastname'],]);
1
2
3
4
5
6
# Retrieves all attributesindex.get_object('myId')# Retrieves firstname and lastname attributesres=index.get_object('myId',{attributesToRetrieve: ['firstname','lastname']})# Retrieves only the firstname attributeres=index.get_object('myId',{attributesToRetrieve: ['firstname']})
1
2
3
4
5
6
7
8
9
10
11
// Retrieves all attributesindex.getObject('myId').then(object=>{console.log(object);});// Retrieves only firstname and lastname attributesindex.getObject('myId',{attributesToRetrieve:['firstname','lastname']}).then(object=>{console.log(object);});
1
2
3
4
5
6
7
8
9
10
11
12
# Retrieves all attributes
index.get_object('myId')# Retrieves firstname and lastname attributes
index.get_object('myId',{'attributesToRetrieve':['firstname, lastname']})# Retrieves only the firstname attribute
index.get_object('myId',{'attributesToRetrieve':['firstname']})
structContact:Codable{letfirstname:Stringletlastname:String?}// Retrieve all attributes.index.getObject(withID:"myId"){(result:Result<Contact,Error>)inifcase.success(letresponse)=result{print("Response: \(response)")}}// Retrieves `firstname` and `lastname` attributes.index.getObject(withID:"myId",attributesToRetrieve:["firstname","lastname"]){(result:Result<Contact,Error>)inifcase.success(letresponse)=result{print("Response: \(response)")}}// Retrieve only the `firstname` attribute.index.getObject(withID:"myId",attributesToRetrieve:["firstname"]){(result:Result<Contact,Error>)inifcase.success(letresponse)=result{print("Response: \(response)")}}
// Retrieves all attributesContactres=index.GetObject<Contact>("myId");// AsynchronousContactres=awaitindex.GetObjectAsync<Contact>("myId");// Retrieves firstname and lastname attributesContactres=index.GetObject<Contact>("myId",attributesToRetrieve:newList<string>{"firstname","lastname"});// AsynchronousContactres=awaitindex.GetObjectAsync<Contact>("myId",attributesToRetrieve:newList<string>{"firstname","lastname"});// Retrieves only the firstname attributeContactres=index.GetObject<Contact>("myId",attributesToRetrieve:newList<string>{"firstname"});// AsynchronousContactres=awaitindex.GetObjectAsync<Contact>("myId",attributesToRetrieve:newList<string>{"firstname"});
// Retrieves all attributesContactcontact=index.getObject("myId");// Async version// CompletableFuture<Contact> contact =index.getObject("myId");// Retrieves firstname and lastname attributesContactcontact=index.getObject("myId",Arrays.asList("firstname","lastname"));// Async version// CompletableFuture<Contact> contact =index.getObject("myId",Arrays.asList("firstname","lastname"));// Retrieves only the firstname attributeContactcontact=index.getObject("myId",Arrays.asList("firstname"));// Async version// CompletableFuture<Contact> contact =index.getObject("myId",Arrays.asList("firstname"));
1
2
3
4
5
6
7
8
// Retrieves the object with all its attributeserr:=index.GetObject("myId",&object)// Retrieves the object with only its `firstname` attributeerr:=index.GetObject("myId",&object,opt.AttributesToRetrieve("firstname"))// Retrieves the object with only its `firstname` and `lastname` attributeserr:=index.GetObject("myId",&object,opt.AttributesToRetrieve("firstname","lastname"))
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Retrieves all attributesclient.execute{getfrom"index"objectId"myId"}// Retrieves firstname and lastname attributesclient.execute{getfrom"index"objectId"myId"attributesToRetrieveSeq("firstname","lastname")}// Retrieves only the firstname attributeclient.execute{getfrom"index"objectId"myId"attributesToRetrieveSeq("firstname")}
If the object ID doesn’t exist in your index,
this method returns an error.
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.
The following example tries to get two records.
The first object ID doesn’t exist: null is returned.
The second object ID exists and the record is returned.
Copy
1
2
3
4
5
6
7
8
9
10
{"results":[null,{"objectID":"1182729442","name":"product 1"}],"message":"ObjectID 1182729441 does not exist."}