algolia_lite 1.2.0
SDKdartflutter
Platformandroidioswindowslinuxmacosweb
Dart API client to interact with Algolia, designed for client apps.
Algolia Dart API Client Lite
Dart API client to interact with Algolia, designed for client apps.
▶️ Getting Started
🔍 Search & Browse
Create an instance of SearchClient:
var client = SearchClient(
applicationID: 'MyApplicationID',
apiKey: 'MyApiKey',
);
Use your search client instance to make API requests:
Search index
const request = SearchRequest(
indexName: 'MyIndexName',
params: SearchParams(
query: 'george clo',
hitsPerPage: 2,
getRankingInfo: true,
),
);
final response = await client.search(request);
Search multiple indices
const params = SearchParams(query: 'van');
const request = MultiSearchRequest(
requests: [
SearchRequest(indexName: 'MyIndexName1', params: params),
SearchRequest(indexName: 'MyIndexName2', params: params),
],
);
final response = await client.multiSearch(request);
Search for facet values
const request = FacetSearchRequest(
indexName: 'MyIndexName',
facetName: 'categories',
facetQuery: 'phone',
);
final response = await client.facetsSearch(request);
Get object(s)
const request = ObjectRequest(
indexName: 'MyIndexName',
objectID: 'MyObjectID',
attributes: ['email', 'name'],
);
final response = await client.object(request);
const request = ObjectsRequest(
requests: [
ObjectRequest(indexName: 'MyIndexName1', objectID: 'MyObjectID1'),
ObjectRequest(indexName: 'MyIndexName1', objectID: 'MyObjectID2'),
],
);
final response = await client.objects(request);
Browse index
const request = SearchRequest('MyIndexName');
final stream = client.browse(request);
await for (final response in stream) {
print(response);
}
💡 Insights
Create InsightsClient:
final client = InsightsClient(
applicationID: 'MyApplicationID',
apiKey: 'MyApiKey',
);
Send events
const event = InsightEvent(
eventType: EventType.click,
eventName: 'Clicked Search Result',
index: 'instant_search',
userToken: 'anonymous-xxxxxx-xx-xxx-xxxxxx',
queryID: '43b15df305339e827f0ac0bdc5ebcaa7',
objectIDs: ['item'],
positions: [1],
);
unawaited(client.sendEvents([event]));
📄 License
Algolia Dart API Client Lite is an open-sourced software licensed under the MIT license. This is an unofficial library, it is not affiliated with nor endorsed by Algolia. Contributions are welcome.