// Retrieves all attributes$index->getObject('myId');// Retrieves only firstname and lastname attributes$index->getObject('myId',['attributeToRetrieve'=>['firstname','lastname'],]);
Copy
1
2
3
4
5
6
# Retrieves all attributesindex.get_object('myId')# Retrieves firstname and lastname attributesres=index.get_object('myId',['firstname','lastname'])# Retrieves only the firstname attributeres=index.get_object('myId',['firstname'])
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Retrieves all attributesindex.getObject('myId',(err,content)=>{console.log(content);});// Retrieves firstname and lastname attributesindex.getObject('myId',['firstname','lastname'],(err,content)=>{console.log(content);});// Retrieves only the firstname attributeindex.getObject('myId',['firstname'],(err,content)=>{console.log(content);});
Copy
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']})
// Retrieve all attributes.index.getObject(withID:"myId",completionHandler:{(content,error)->{// do something})// Retrieves `firstname` and `lastname` attributes.index.getObject(withID:"myId",attributesToRetrieve:["firstname","lastname"],completionHandler:{(content,error)->{// do something})// Retrieve only the `firstname` attribute.index.getObject(withID:"myId",attributesToRetrieve:["firstname"],completionHandler:{(content,error)->{// do something})
// Retrieves all attributesindex.getObjectAsync("myId",newCompletionHandler(){@OverridepublicvoidrequestCompleted(JSONObjectcontent,AlgoliaExceptionerror){// [...]}});// Retrieves the firstname and lastname attributeindex.getObjectAsync("myId",Arrays.asList("firstname","lastname"),newCompletionHandler(){@OverridepublicvoidrequestCompleted(JSONObjectcontent,AlgoliaExceptionerror){// [...]}});// Retrieves only the firstname attributeindex.getObjectAsync("myId",Arrays.asList("firstname"),newCompletionHandler(){@OverridepublicvoidrequestCompleted(JSONObjectcontent,AlgoliaExceptionerror){// [...]}});
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// 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"));
Copy
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"))
Copy
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")}
letrequestOptions=RequestOptions()requestOptions.headers["X-Algolia-User-ID"]="user123"index.getObjects(withIDs:["myId1","myId2"],requestOptions:requestOptions,completionHandler:{(content,error)->{// do something})
In this section we document the JSON response returned by the API.
Each language will encapsulate this response inside objects specific to the language and/or the implementation.
So the actual type in your language might differ from what is documented.
Here is an example where we try to get two objects.
The first one doesn’t exist (null is returned) but the second one does
(the object is returned).
If an object does not exist, null will be return instead.
Copy
1
2
3
4
5
6
7
8
9
10
{"results":[null,{"objectID":"1182729442","name":"product 1"}],"message":"ObjectID 1182729442 does not exist."}