Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this package support fetch popular searches? #130

Open
zoufishanmehdi opened this issue Mar 7, 2024 · 0 comments
Open

Does this package support fetch popular searches? #130

zoufishanmehdi opened this issue Mar 7, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@zoufishanmehdi
Copy link

zoufishanmehdi commented Mar 7, 2024

Is your feature request related to a problem? Please describe.
I know Algolia Analytics API has a way to fetch popular searches but wondering if there's a way to do it with this package

Describe the solution you'd like
If there's a simple way to fetch top popular searches, then it would make it easier to fully use this functionality in search

Describe alternatives you've considered
Directly implementing Algolia Analytics API but it doesn't seem to work yet

`Future fetchPopularSearches() async {
final String url = 'https://analytics.algolia.com/1/searches/popular?indexName=YOUR_INDEX_NAME';
final String appId = 'YOUR_APP_ID'; // Ensure this is secured and not hardcoded.
final String apiKey = 'YOUR_API_KEY'; // Ensure this is secured and not hardcoded.

try {
final response = await http.get(
Uri.parse(url),
headers: {
'X-Algolia-Application-Id': appId,
'X-Algolia-API-Key': apiKey,
},
);

if (response.statusCode == 200) {
  final data = json.decode(response.body);
  print('$popularSearchesKey: $data');
  // You can use popularSearchesKey as a reference for caching the response
} else {
  print('Failed to fetch $popularSearchesKey: ${response.reasonPhrase}');
  // Handle non-200 responses
}

} catch (e) {
print('Error fetching $popularSearchesKey: $e');
// Handle network errors, parsing errors, etc.
}
}`

@zoufishanmehdi zoufishanmehdi added the enhancement New feature or request label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant