Integrate Aidaptive Predictive Recommendations and Search in your React, React Native, Next JS, Angular or other client side npm frameworks.
- Install aidaptive-sdk with npm
npm install aidaptive-sdk
- Add the Jarvis ML CDN "id" script in your project's index.html file:
<script src=“https://cdn.jarvisml.com/jarvisml-id.min.js?cid=your-cid&vertical=your-vertical”></script>
See https://app.aidaptive.com/documentation for more details about parameters you can pass, for example customer_id and item_id.
import { Component } from '@angular/core';
import { getRecommendations, PublicEntity } from 'aidaptive-sdk';
export class AppComponent {
results: PublicEntity[] = [];
constructor() {
this.getResults();
}
async getResults() {
const response = await getRecommendations({
recommendationsCount: 4, // Recommendations Count
pageType: "home", // Source of the Request (Home, PropertyDetails, ...)
locationFilter: "paris" // Location Name
});
if (!response) throw new Error('request failed');
this.results = response.recommendations;
}
}
import { Component } from '@angular/core';
import { getSearchResults, VariantData, PublicEntity } from 'aidaptive-sdk';
export class AppComponent {
results: PublicEntity[] = [];
constructor() {
this.getResults();
}
async getResults() {
const filters = new VariantData()
.setValue('search_text', 'beach')
.setValueIfTruthy('max_price', 3000)
.setValueIfTruthy('min_bedrooms', 4)
.setValueIfTruthy('min_bathrooms', 3); // See sample pages for more examples
const response = await getSearchResults({
filters, // Search filters
pageSize: 10, // Results per page
});
if (!response) throw new Error('request failed');
this.results = response.results;
}
}
For more information, email us: support@aidaptive.com