We released a new version of the PHP API client in public beta.
Read the beta documentation for more information.
We released a new version of the JavaScript API client in public beta.
Read the beta documentation for more information.
We released a new version of the Java API client in public beta.
Read the beta documentation for more information.
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.
# Asynchronous call and wait until completeresponse=index.add_object({firstname: 'Jimmie',lastname: 'Barninger'})response.wait# Synchronous call, that handles the wait internallyindex.add_object!({firstname: 'Jimmie',lastname: 'Barninger'})
structContact:Codable{letfirstName:StringletlastName:String}letobject=Contact(firstName:"Jimmie",lastName:"Barninger")tryindex.saveObject(object,autoGeneratingObjectID:true){resultinifcase.success(letwaitableWrapper)=result{waitableWrapper.wait(){resultinifcase.success(letresponse)=result{print("New object is indexed")}}}}
BatchIndexingResponseresp=index.saveObject(newContact().setFirstname("Jimmie").setLastname("Barninger"));// All objects implementing the AlgoliaWaitableResponse interface// Can be awaited with the .waitTask() methodresp.waitTask();
structContact:Codable{letfirstName:StringletlastName:String}letobject=Contact(firstName:"Jimmie",lastName:"Barninger")varrequestOptions=RequestOptions()requestOptions.headers=["X-Algolia-User-ID":"user123"]tryindex.saveObject(object,autoGeneratingObjectID:true){resultinifcase.success(letwaitableWrapper)=result{waitableWrapper.wait(requestOptions:requestOptions){resultinifcase.success(letresponse)=result{print("New object is indexed")}}}}
BatchIndexingResponseresp=index.saveObject(newContact().setFirstname("Jimmie").setLastname("Barninger"),newRequestOptions().addExtraHeader("X-Algolia-User-ID","user123"));// All objects implementing the AlgoliaWaitableResponse interface// Can be awaited with the .waitTask() methodresp.waitTask();
for{t<-client.execute{indexinto"toto"`object`MyObject("test")}r<-client.execute{waitFortasktfrom"toto"optionsRequestOptions(extraHeaders=Some(Map("X-Algolia-User-ID"=>"user123")))}}yield"indexing is done"